baidubce / bce-qianfan-sdk

Provide best practices for LMOps, as well as elegant and convenient access to the features of the Qianfan MaaS Platform. (提供大模型工具链最佳实践,以及优雅且便捷地访问千帆大模型平台)
https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html
Apache License 2.0
324 stars 49 forks source link

GO SDK支持一下系统记忆API #711

Closed Heming9 closed 2 months ago

Heming9 commented 2 months ago

Feature request

如标题, 目前只有python的, 或者有什么办法能通过SDK发送带鉴权的请求也行, 减少重复工作

contribution or solutions

No response

danielhjz commented 2 months ago

感谢反馈,可以使用以下方式调用平台功能API,例如系统记忆API的创建接口:

需要 gosdk >= v0.0.10

package main

import (
    "context"
    "fmt"

    "github.com/baidubce/bce-qianfan-sdk/go/qianfan"
)

func main() {
    qianfan.GetConfig().AccessKey = "your_access_key"
    qianfan.GetConfig().SecretKey = "your_secret_key"
    ca := qianfan.NewConsoleAction()
    res, err := ca.Call(context.TODO(), "/v2/memory", "CreateSystemMemory", map[string]interface{}{
        "appId":       "26xxxxx42",
        "description": "test da系统人设描述",
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(string(res.Body))
}

对应的examples我们也会同步更新

Feature request

如标题, 目前只有python的, 或者有什么办法能通过SDK发送带鉴权的请求也行, 减少重复工作

contribution or solutions

No response