浏览代码

fix: 带有 userId 参数时请求 azure 会导致 500 错误。 (#234)

Co-authored-by: 黄宝成 <huangbc@publink.cn>
little_huang 1 年之前
父节点
当前提交
8f6fd87849
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      pkg/chatgpt/context.go

+ 5 - 1
pkg/chatgpt/context.go

@@ -165,6 +165,10 @@ func (c *ChatGPT) ChatWithContext(question string) (answer string, err error) {
 		return "", OverMaxTextLength
 	}
 	model := public.Config.Model
+	userId := c.userId
+	if public.Config.AzureOn {
+		userId = ""
+	}
 	if model == openai.GPT3Dot5Turbo0301 ||
 		model == openai.GPT3Dot5Turbo ||
 		model == openai.GPT4 || model == openai.GPT40314 ||
@@ -179,7 +183,7 @@ func (c *ChatGPT) ChatWithContext(question string) (answer string, err error) {
 			},
 			MaxTokens:   c.maxAnswerLen,
 			Temperature: 0.6,
-			User:        c.userId,
+			User:        userId,
 		}
 		resp, err := c.client.CreateChatCompletion(c.ctx, req)
 		if err != nil {