fix: initialize Parts slice in genai.Content struct to prevent nil pointer errors

## CHANGES

- Initialize Parts slice with empty slice in Content struct
- Prevent potential nil pointer dereference during message conversion
- Ensure Parts field is ready for append operations
- Improve robustness of convertMessages function in Gemini client
This commit is contained in:
Kayvan Sylvan
2025-07-26 12:06:39 -07:00
parent 71c08648c6
commit c766915764

View File

@@ -323,7 +323,7 @@ func (o *Client) convertMessages(msgs []*chat.ChatCompletionMessage) []*genai.Co
var contents []*genai.Content
for _, msg := range msgs {
content := &genai.Content{}
content := &genai.Content{Parts: []*genai.Part{}}
if msg.Content != "" {
content.Parts = append(content.Parts, &genai.Part{Text: msg.Content})