|
|
@@ -596,6 +596,7 @@ func streamResponseGeminiChat2OpenAI(geminiResponse *GeminiChatResponse) (*dto.C
|
|
|
}
|
|
|
var texts []string
|
|
|
isTools := false
|
|
|
+ isThought := false
|
|
|
if candidate.FinishReason != nil {
|
|
|
// p := GeminiConvertFinishReason(*candidate.FinishReason)
|
|
|
switch *candidate.FinishReason {
|
|
|
@@ -620,6 +621,9 @@ func streamResponseGeminiChat2OpenAI(geminiResponse *GeminiChatResponse) (*dto.C
|
|
|
call.SetIndex(len(choice.Delta.ToolCalls))
|
|
|
choice.Delta.ToolCalls = append(choice.Delta.ToolCalls, *call)
|
|
|
}
|
|
|
+ } else if part.Thought {
|
|
|
+ isThought = true
|
|
|
+ texts = append(texts, part.Text)
|
|
|
} else {
|
|
|
if part.ExecutableCode != nil {
|
|
|
texts = append(texts, "```"+part.ExecutableCode.Language+"\n"+part.ExecutableCode.Code+"\n```\n")
|
|
|
@@ -632,7 +636,11 @@ func streamResponseGeminiChat2OpenAI(geminiResponse *GeminiChatResponse) (*dto.C
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- choice.Delta.SetContentString(strings.Join(texts, "\n"))
|
|
|
+ if isThought {
|
|
|
+ choice.Delta.SetReasoningContent(strings.Join(texts, "\n"))
|
|
|
+ } else {
|
|
|
+ choice.Delta.SetContentString(strings.Join(texts, "\n"))
|
|
|
+ }
|
|
|
if isTools {
|
|
|
choice.FinishReason = &constant.FinishReasonToolCalls
|
|
|
}
|