[PR #13523] [CLOSED] openai: do not separate images into their own messages #76549

Closed
opened 2026-05-05 09:10:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13523
Author: @BruceMacD
Created: 12/18/2025
Status: Closed

Base: mainHead: brucemacd/oai-chat-req-multipart


📝 Commits (1)

  • f82d00a openai: do not separate images into their own messages

📊 Changes

2 files changed (+42 additions, -23 deletions)

View changed files

📝 openai/openai.go (+16 -13)
📝 openai/openai_test.go (+26 -10)

📄 Description

The FromChatRequest function incorrectly splits multi-part OpenAI messages into separate messages.

Problem

When receiving an OpenAI chat completion request with multi-part content:

  {
    "role": "user",
    "content": [
      {"type": "text", "text": "Describe this image."},
      {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
    ]
  }

The FromChatRequest function creates two separate api.Message structs:

  1. api.Message{Role: "user", Content: "Describe this image."}
  2. api.Message{Role: "user", Images: []api.ImageData{img}}

Expected

OpenAI expects multi-part content to remain as a single message. The function should produce ONE message that preserves both the text and image together.

  • Changed the case []any: branch to accumulate text and images into slices first, then create a single api.Message at the end
  • Multiple text parts are joined with \n\n
  • All images are collected into a single Images slice

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13523 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 12/18/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `brucemacd/oai-chat-req-multipart` --- ### 📝 Commits (1) - [`f82d00a`](https://github.com/ollama/ollama/commit/f82d00af74e8874861397ac6a05f35988cc45a52) openai: do not separate images into their own messages ### 📊 Changes **2 files changed** (+42 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `openai/openai.go` (+16 -13) 📝 `openai/openai_test.go` (+26 -10) </details> ### 📄 Description The `FromChatRequest` function incorrectly splits multi-part OpenAI messages into separate messages. ## Problem When receiving an OpenAI chat completion request with multi-part content: ```json { "role": "user", "content": [ {"type": "text", "text": "Describe this image."}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}} ] } ``` The FromChatRequest function creates two separate api.Message structs: 1. api.Message{Role: "user", Content: "Describe this image."} 2. api.Message{Role: "user", Images: []api.ImageData{img}} ## Expected OpenAI expects multi-part content to remain as a single message. The function should produce ONE message that preserves both the text and image together. - Changed the case []any: branch to accumulate text and images into slices first, then create a single api.Message at the end - Multiple text parts are joined with \n\n - All images are collected into a single Images slice --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 09:10:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#76549