https://github.com/hanson/coze-go
coze 的 golang sdk,支持最新的 oauth jwt 授权
https://github.com/hanson/coze-go
coze
Last synced: 6 months ago
JSON representation
coze 的 golang sdk,支持最新的 oauth jwt 授权
- Host: GitHub
- URL: https://github.com/hanson/coze-go
- Owner: Hanson
- License: mit
- Created: 2024-12-06T08:47:32.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-01-10T12:04:52.000Z (9 months ago)
- Last Synced: 2025-04-23T08:18:23.648Z (6 months ago)
- Topics: coze
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
本项目持续更新中,你可以参考 oauth 中如何进行 jwt 授权,也欢迎催更(催一个接口更一个)
# Install
```
go get github.com/hanson/coze-go
```# Usage
## 授权
```
// 获取授权对象
oauth := auth.NewOauth("appid", "kid").WithPemByte([]byte("xxx"))// 获取授权token
oauth.GetToken()
```## 会话
```
// 创建会话对象
c := NewConversation(o)// 创建会话
c.CreateConversation(&CreateConversationReq{})
```## 对话
```
// 创建对话对象
c := chat.NewChat(o)// 发起对话
c.Chat(conversationId, &chat.ChatReq{
BotId: "xxx",
UserId: "test",
AdditionalMessages: []*common.Message{
{
Role: "user",
Content: `你是谁?`,
},
},
CustomVariables: map[string]string{},
Stream: false,
AutoSaveHistory: true,
})
// 查看对话详情
c.Retrieve(conversationId, chatRsp.Data.Id)
// 查看对话消息详情
c.MessageList(conversationId, chatRsp.Data.Id)
```## 工作流
```
// 创建工作流对象
w := workflow.NewWorkflow(o)
// 执行工作流
w.WorkflowRun(&workflow.WorkflowRunReq{
WorkflowId: "",
Parameters: map[string]interface{}{
"USER_INPUT": `你好`,
"CONVERSATION_NAME": "Default",
},
})
```