fixed bug for function call for openai

This commit is contained in:
RockYang
2024-07-16 06:24:40 +08:00
parent 282f55c7a3
commit 42bc23cacf
3 changed files with 6 additions and 13 deletions

View File

@@ -65,7 +65,7 @@ func (h *ChatHandler) sendOpenAiMessage(
if !strings.Contains(line, "data:") || len(line) < 30 {
continue
}
logger.Info(line)
var responseBody = types.ApiResponse{}
err = json.Unmarshal([]byte(line[6:]), &responseBody)
if err != nil { // 数据解析出错
@@ -74,7 +74,7 @@ func (h *ChatHandler) sendOpenAiMessage(
if len(responseBody.Choices) == 0 { // Fixed: 兼容 Azure API 第一个输出空行
continue
}
if responseBody.Choices[0].Delta.Content == nil {
if responseBody.Choices[0].Delta.Content == nil && responseBody.Choices[0].Delta.ToolCalls == nil {
continue
}