Skip to content

Commit df153f2

Browse files
committed
fix: text modality returns results consistent with before
1 parent 149843c commit df153f2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

components/model/gemini/gemini.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -980,16 +980,14 @@ func (cm *ChatModel) convCandidate(candidate *genai.Candidate) (*schema.Message,
980980
}
981981

982982
var (
983-
texts []string
984-
outParts []schema.MessageOutputPart
985-
contentBuilder strings.Builder
983+
texts []string
984+
outParts []schema.MessageOutputPart
986985
)
987986
for _, part := range candidate.Content.Parts {
988987
if part.Thought {
989988
result.ReasoningContent = part.Text
990989
} else if len(part.Text) > 0 {
991990
texts = append(texts, part.Text)
992-
contentBuilder.WriteString(part.Text)
993991
outParts = append(outParts, schema.MessageOutputPart{
994992
Type: schema.ChatMessagePartTypeText,
995993
Text: part.Text,
@@ -1024,8 +1022,10 @@ func (cm *ChatModel) convCandidate(candidate *genai.Candidate) (*schema.Message,
10241022
outParts = append(outParts, outPart)
10251023
}
10261024
}
1027-
result.Content = contentBuilder.String()
1028-
if len(texts) > 1 {
1025+
1026+
if len(texts) == 1 {
1027+
result.Content = texts[0]
1028+
} else if len(texts) > 1 {
10291029
for _, text := range texts {
10301030
result.MultiContent = append(result.MultiContent, schema.ChatMessagePart{
10311031
Type: schema.ChatMessagePartTypeText,

0 commit comments

Comments
 (0)