兼容新的mongo方法格式,并且修复client的apitoken覆盖问题
This commit is contained in:
@@ -34,9 +34,10 @@ type CreateChatRes struct {
|
||||
|
||||
// UpdateChatReq 更新对话配置请求
|
||||
type UpdateChatReq struct {
|
||||
Name string `json:"name,omitempty"` // 对话配置名称
|
||||
DatasetIds []string `json:"dataset_ids,omitempty"` // 关联的知识库ID列表
|
||||
Prompt *PromptConfig `json:"prompt,omitempty"` // 提示词配置
|
||||
Name string `json:"name,omitempty"` // 对话配置名称
|
||||
Description string `json:"description,omitempty"` // 对话描述
|
||||
DatasetIds []string `json:"dataset_ids,omitempty"` // 关联的知识库ID列表(RAGFlow API使用下划线格式)
|
||||
Prompt *PromptConfig `json:"prompt,omitempty"` // 提示词配置
|
||||
}
|
||||
|
||||
// 聊天助手管理
|
||||
@@ -122,6 +123,11 @@ func (c *Client) CreateChat(ctx context.Context, req *CreateChatReq) (*Chat, err
|
||||
if res.Code != 0 {
|
||||
return nil, gerror.Newf("create chat failed: %s", res.Msg)
|
||||
}
|
||||
// 检查响应数据是否为空:防止RAGFlow API返回 {"code":0, "data":null}
|
||||
// 如果不检查直接返回,调用方会收到 (nil, nil),导致空指针异常
|
||||
if res.Data == nil {
|
||||
return nil, gerror.Newf("create chat returned null data: %s", res.Msg)
|
||||
}
|
||||
return res.Data, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user