Support Responses API#242
Open
Halcyonhal9 wants to merge 2 commits into
Open
Conversation
ChunkTypes mirrors the OpenAI Chat Completions content types ("text",
"image_url", ...). The OpenAI Responses API spells text and image content
differently — "input_text"/"output_text" for text and "input_image" for
images — so parsing structured Responses content raised e.g.
"'input_text' is not a valid ChunkTypes" / "'input_image' is not a valid
ChunkTypes" (surfacing as a 400 when a model is served behind an
OpenAI-compatible Responses endpoint).
Map the Responses content type spellings onto their Chat Completions
equivalents in _convert_openai_content_chunks via a small alias table
(input_text/output_text -> text, input_image -> image_url). The chunk's type
field is rewritten because the discriminated chunk models require the canonical
type; input_image's image_url is a bare string, which ImageURLChunk already
accepts. Adds regression tests for text and image.
Resolve conflicts from mistralai#241 (consolidated ContentChunk, removed UserContentChunk) and mistralai#245 (audio data URL handling): - chunk.py: apply Responses-API content-type aliases on top of the consolidated ContentChunk; drop the removed UserContentChunk alias. - tests/test_converters.py: keep both ChunkTypes and ContentChunk imports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accept Responses API input_text/output_text/input_image content types
What
Change
_convert_openai_content_chunksto also accept the OpenAI Responses APIcontent types
input_text,output_text(→TextChunk) andinput_image(→
ImageURLChunk).Why
ChunkTypesmirrors the OpenAI Chat Completions content types (text,image_url, ...).The Responses API
names text and image content differently —
input_text/output_textfor textand
input_imagefor images. This means parsing structured Responses content failswith e.g.
'input_text' is not a valid ChunkTypes/'input_image' is not a valid ChunkTypes.This breaks the Responses API for Mistral models served on vLLM. Serving a
Mistral model on vLLM 0.23.0 (with
mistral_common1.11.3) using--tokenizer-mode mistraland exposing/v1/responseshands request contentstraight to
mistral_common. A client sending the standard Responses inputshape —
{"type": "input_text", "text": "..."}or{"type": "input_image", "image_url": "..."}, which the official OpenAI clientlibraries emit — gets an HTTP 400, making
/v1/responsesunusable for textand image input alike.
The proposed change
Map the Responses content-type spellings onto their Chat Completions
equivalents in
_convert_openai_content_chunksvia a small alias table(
input_text/output_text→text,input_image→image_url). The chunk'stypefield is rewritten because the discriminated chunk models require thecanonical
type;input_image'simage_urlis a bare string, whichImageURLChunkalready accepts.Tests / checks
input_text/output_text) and image(
input_image) content.pytest tests/test_converters.py→ 116 passed.ruff check,ruff format --check,mypy→ all clean.A patched version of mistral_common 1.11.3 was tested on vLLM 0.23.0, using hf model mistralai/Mistral-Medium-3.5-128B and the responses api.