-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdify.go
More file actions
57 lines (49 loc) · 2.04 KB
/
dify.go
File metadata and controls
57 lines (49 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Package dify provides a Go client library for Dify AI platform APIs
package godify
import (
"github.com/kingfs/godify/console"
"github.com/kingfs/godify/dataset"
"github.com/kingfs/godify/files"
"github.com/kingfs/godify/mcp"
"github.com/kingfs/godify/service"
"github.com/kingfs/godify/web"
)
// NewServiceClient 创建 Service API 客户端
// appToken: 应用 API Token
// baseURL: Dify 服务器地址,例如 "https://api.dify.ai"
func NewServiceClient(appToken, baseURL string) *service.Client {
return service.NewClient(appToken, baseURL)
}
// NewWebClient 创建 Web API 客户端
// appCode: 应用代码,可以从Dify控制台获取
// baseURL: Dify 服务器地址,例如 "https://api.dify.ai"
func NewWebClient(baseURL string) *web.Client {
return web.NewClient(baseURL)
}
// NewConsoleClient 创建 Console API 客户端 (管理员API)
// accessToken: 访问令牌或会话令牌
// baseURL: Dify 服务器地址,例如 "https://api.dify.ai"
func NewConsoleClient(accessToken, baseURL string) *console.Client {
return console.NewClient(accessToken, baseURL)
}
// NewConsoleClientWithSession 使用Session Cookie创建 Console API 客户端
// sessionCookie: 会话Cookie
// baseURL: Dify 服务器地址,例如 "https://api.dify.ai"
func NewConsoleClientWithSession(sessionCookie, baseURL string) *console.Client {
return console.NewClientWithSession(sessionCookie, baseURL)
}
// NewFilesClient 创建 Files API 客户端
// baseURL: Dify 服务器地址,例如 "https://api.dify.ai"
func NewFilesClient(baseURL string) *files.Client {
return files.NewClient(baseURL)
}
// NewMCPClient 创建 MCP API 客户端 (Model Context Protocol)
// baseURL: Dify 服务器地址,例如 "https://api.dify.ai"
func NewMCPClient(baseURL string) *mcp.Client {
return mcp.NewClient(baseURL)
}
// NewDatasetClient 创建Dataset API客户端 (面向数据集管理)
// datasetToken: 数据集API Token,可以从Dify控制台获取
func NewDatasetClient(datasetToken, baseURL string) *dataset.Client {
return dataset.NewClient(datasetToken, baseURL)
}