This repository was archived by the owner on Sep 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -69,19 +69,16 @@ func (g *geminiClient) convertMessages(messages []message.Message) []*genai.Cont
6969 Role : "user" ,
7070 })
7171 case message .Assistant :
72- content := & genai.Content {
73- Role : "model" ,
74- Parts : []* genai.Part {},
75- }
72+ var assistantParts []* genai.Part
7673
7774 if msg .Content ().String () != "" {
78- content . Parts = append (content . Parts , & genai.Part {Text : msg .Content ().String ()})
75+ assistantParts = append (assistantParts , & genai.Part {Text : msg .Content ().String ()})
7976 }
8077
8178 if len (msg .ToolCalls ()) > 0 {
8279 for _ , call := range msg .ToolCalls () {
8380 args , _ := parseJsonToMap (call .Input )
84- content . Parts = append (content . Parts , & genai.Part {
81+ assistantParts = append (assistantParts , & genai.Part {
8582 FunctionCall : & genai.FunctionCall {
8683 Name : call .Name ,
8784 Args : args ,
@@ -90,7 +87,12 @@ func (g *geminiClient) convertMessages(messages []message.Message) []*genai.Cont
9087 }
9188 }
9289
93- history = append (history , content )
90+ if len (assistantParts ) > 0 {
91+ history = append (history , & genai.Content {
92+ Role : "model" ,
93+ Parts : assistantParts ,
94+ })
95+ }
9496
9597 case message .Tool :
9698 for _ , result := range msg .ToolResults () {
You can’t perform that action at this time.
0 commit comments