https://github.com/fzdwx/dify
Dify Golang Client
https://github.com/fzdwx/dify
dify dify-client go
Last synced: 8 months ago
JSON representation
Dify Golang Client
- Host: GitHub
- URL: https://github.com/fzdwx/dify
- Owner: fzdwx
- License: mit
- Created: 2025-05-22T09:17:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-09T08:58:33.000Z (about 1 year ago)
- Last Synced: 2025-06-18T09:41:17.636Z (about 1 year ago)
- Topics: dify, dify-client, go
- Language: Go
- Homepage:
- Size: 2.33 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dify Golang Client
dify 的 Golang 客户端,用于管理数据集、创建应用等。
## 快速开始
```go
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/fzdwx/dify"
)
func main() {
// 使用用户名和密码创建客户端
// 客户端会自动登录并获取或创建 datasets API key
client, err := dify.NewClient("http://your-dify-host", "your-email", "your-password")
if err != nil {
log.Fatal("创建客户端失败:", err)
}
ctx := context.Background()
// 创建数据集
uniqueName := fmt.Sprintf("测试数据集_%d", time.Now().Unix())
resp, err := client.CreateEmptyDataset(ctx, &dify.CreateEmptyDatasetRequest{
Name: uniqueName,
Description: "测试数据集",
IndexingTechnique: dify.IndexingTechniqueEconomy,
Permission: dify.DatasetPermissionAllTeamMembers,
Provider: dify.DatasetProviderVendor,
RetrievalModel: dify.RetrievalModel{
SearchMethod: dify.RetrievalModelSearchMethodHybridSearch,
RerankingEnable: true,
TopK: 10,
},
})
if err != nil {
log.Fatal("创建数据集失败:", err)
}
fmt.Printf("成功创建数据集: %s (ID: %s)\n", resp.Result.Name, resp.Result.ID)
}
```
## 许可证
MIT License