mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-11 19:03:43 +08:00
fix: update text handling to ensure nil checks and pointer usage for message content
This commit is contained in:
@@ -20,7 +20,7 @@ var ModelsSupportSystemInstruction = []string{
|
||||
"gemini-2.0-flash", "gemini-2.0-flash-exp",
|
||||
"gemini-2.0-flash-thinking-exp-01-21",
|
||||
"gemini-2.0-flash-lite",
|
||||
"gemini-2.0-flash-exp-image-generation",
|
||||
// "gemini-2.0-flash-exp-image-generation",
|
||||
"gemini-2.0-pro-exp-02-05",
|
||||
}
|
||||
|
||||
|
||||
@@ -109,9 +109,9 @@ func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest {
|
||||
var parts []Part
|
||||
imageNum := 0
|
||||
for _, part := range openaiContent {
|
||||
if part.Type == model.ContentTypeText {
|
||||
if part.Type == model.ContentTypeText && part.Text != nil && *part.Text != "" {
|
||||
parts = append(parts, Part{
|
||||
Text: part.Text,
|
||||
Text: *part.Text,
|
||||
})
|
||||
} else if part.Type == model.ContentTypeImageURL {
|
||||
imageNum += 1
|
||||
@@ -276,7 +276,7 @@ func responseGeminiChat2OpenAI(response *ChatResponse) *openai.TextResponse {
|
||||
// Add to content items
|
||||
contentItems = append(contentItems, model.MessageContent{
|
||||
Type: model.ContentTypeText,
|
||||
Text: part.Text,
|
||||
Text: &part.Text,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user