diff --git a/proto/im.go b/proto/im.go index bf77294..35125fe 100644 --- a/proto/im.go +++ b/proto/im.go @@ -37,13 +37,15 @@ type WSMessageReq struct { } type ModelParam struct { - Model string `json:"model"` //模型名称 - Domain string `json:"domain"` //domain参数,spark需要 - Url string `json:"url"` //模型地址 - APPID string `json:"appid"` //应用id - APISecret string `json:"apiSecret"` //应用密钥 - APIKey string `json:"apiKey"` //应用key - System string `json:"system"` //系统参数 + Model string `json:"model"` //模型名称 + Domain string `json:"domain"` //domain参数,spark需要 + Url string `json:"url"` //模型地址 + APPID string `json:"appid"` //应用id + APISecret string `json:"apiSecret"` //应用密钥 + APIKey string `json:"apiKey"` //应用key + System string `json:"system"` //系统参数 + AccessKey string `json:"access_key"` //accessKey参数 + SecretKey string `json:"Secret_key"` //secretKey参数 //其他参数 Temperature float32 `json:"temperature"` //温度,默认0.5,核采样阈值。取值越高随机性越强,即相同的问题得到的不同答案的可能性越大 MaxTokens int `json:"maxTokens"` //最大生成长度,默认4096 diff --git a/service/qianfan.go b/service/qianfan.go index 771696f..5a0332a 100644 --- a/service/qianfan.go +++ b/service/qianfan.go @@ -14,8 +14,14 @@ import ( ) func Qianfan(modelParam proto.ModelParam, imCtx *proto.IMParamContext) { - qianfan.GetConfig().AccessKey = proto.QianfanAccessKey - qianfan.GetConfig().SecretKey = proto.QianfanSecretKey + log.Println("qianfan model param:", modelParam) + log.Println("qianfan question:", imCtx.Question) + if modelParam.AccessKey == "" || modelParam.APISecret == "" { + log.Println("qianfan AccessKey or APISecret is empty") + return + } + qianfan.GetConfig().AccessKey = modelParam.AccessKey + qianfan.GetConfig().SecretKey = modelParam.APISecret chat := qianfan.NewChatCompletion(qianfan.WithModel(modelParam.Model)) var messages []qianfan.ChatCompletionMessage