本人始终推荐您使用官方SDK!!!
通用模型
图像大模型
超拟人大模型
向量模型
模型微调
搜索工具
Batch API
知识管理
go get -u github.com/itcwc/go-zhipu
import "github.com/itcwc/go-zhipu"
package examples
import (
"fmt"
"time"
zhipu "github.com/itcwc/go-zhipu/model_api"
"github.com/itcwc/go-zhipu/utils"
)
func Example() {
apiKey := "your api key"
// token 填写你自己得或使用扩展中的方法生成
expireAtTime := int64(1719803252) // token 过期时间
token, _ := utils.GenerateToken(apiKey, expireAtTime)
// token缓存处理等 。。。
mssage := zhipu.PostParams{
Model: "glm-3-turbo",
Messages: []zhipu.Message{
{
Role: "user", // 消息的角色信息 详见文档
Content: "content", // 消息内容
},
},
}
var t time.Duration = 60 // 请求等待时间 可不填 默认60秒
postResponse, err := zhipu.BeCommonModel( mssage, token, t)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(postResponse)
}
通用模型
// sse调用
go-zhipu.model_api.BeCommonModel(postParams PostParams, token string, time ...time.Duration)
// 异步调用
go-zhipu.model_api.ModelAsynchronousCall(postParams PostParams, token string, time ...time.Duration)
// 任务结果查询
go-zhipu.model_api.ModelTaskResultQuery(id int, token string, time ...time.Duration)
图像大模型
go-zhipu.model_api.ImageLargeModel(prompt string, model string, userId string, token string, time ...time.Duration)
超拟人大模型
// 同步调用
go-zhipu.model_api.SuperhumanoidModel(postParams PostSuperhumanoidParams, token string, time ...time.Duration)
// 异步调用
go-zhipu.model_api.SHMAsyncCall(postParams PostSuperhumanoidParams, token string, time ...time.Duration)
向量模型
go-zhipu.model_api.VectorModel(input string, model string, token string, time ...time.Duration)
Batch API
// 创建 Batch
go-zhipu.model_api.BatchAPICreate(postParams PostBatchParams, token string, time ...time.Duration)
// 检索 Batch
go-zhipu.model_api.BatchSearch(batchId int, token string, time ...time.Duration)
// 取消 Batch
go-zhipu.model_api.BatchCancel(batchId int, token string, time ...time.Duration)
// 列出 Batch
go-zhipu.model_api.BatchList(after string, limit int, token string, time ...time.Duration)
// 下载 Batch 结果
go-zhipu.model_api.BatchDownload(fileId int, token string, time ...time.Duration)
模型微调
// 创建微调任务
go-zhipu.model_api.CreateModelFineTuning(trainingFile string, model string, token string, time ...time.Duration)
// 查询微调任务事件
go-zhipu.model_api.QueryModelFineTuningEvent(jobId int, after string, limit int, token string, time ...time.Duration)
// 查询微调任务
go-zhipu.model_api.QueryModelFineTuning(jobId int, after string, limit int, token string, time ...time.Duration)
// 查询个人微调任务
go-zhipu.model_api.QueryPersonalModelFineTuning(after string, limit int, token string, time ...time.Duration)
// 删除微调任务
go-zhipu.model_api.DeleteModelFineTuning(jobId int, token string, time ...time.Duration)
// 取消微调任务
go-zhipu.model_api.CancelModelFineTuning(jobId int, token string, time ...time.Duration)
// 删除微调模型
go-zhipu.model_api.DeleteModelFineTuningModel(fineTunedModel string, token string, time ...time.Duration)
搜索工具
// Web-Search-Pro
go-zhipu.model_api.SearchTool(postParams PostSearchParams, token string, time ...time.Duration)
知识管理
// 创建知识库
go-zhipu.model_api.Knowledge(postParams PostKnowledgeParams, model string, token string, time ...time.Duration)
// 编辑知识库
go-zhipu.model_api.EditKnowledge(postParams PostKnowledgeItemParams, token string, time ...time.Duration)
// 检索知识库列表
go-zhipu.model_api.QueryKnowledgeList(page int, size int, token string, time ...time.Duration)
// 删除知识库
go-zhipu.model_api.DeleteKnowledge(knowledgeId string, token string, time ...time.Duration)
// 知识库使用量查询
go-zhipu.model_api.KnowledgeUsage(token string, time ...time.Duration)
// 文件管理
go-zhipu.model_api.FileManagement(purpose string, model string, file *FileHeader, token string, time ...time.Duration)
// 编辑知识库文件
go-zhipu.model_api.EditKnowledgeFile(postParams KnowledgeFileParams, token string, time ...time.Duration)
// 查询文件列表
go-zhipu.model_api.QueryFileList(postParams QueryFileListParams, token string, time ...time.Duration)
// 删除知识库文件
go-zhipu.model_api.DeleteKnowledgeFile(id string, token string, time ...time.Duration)
// 查询知识库文件详情
go-zhipu.model_api.QueryKnowledgeFileDetail(id string, token string, time ...time.Duration)
由 contrib.rocks 自动生成。