Skip to content

fix: /v1/embeddings now returns OpenAI shape (OQP-4)#7

Merged
TadMSTR merged 1 commit into
mainfrom
fix/oqp-4-embeddings-openai-shape
Jun 23, 2026
Merged

fix: /v1/embeddings now returns OpenAI shape (OQP-4)#7
TadMSTR merged 1 commit into
mainfrom
fix/oqp-4-embeddings-openai-shape

Conversation

@TadMSTR

@TadMSTR TadMSTR commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • dispatch_request treated any response with transfer-encoding: chunked as streaming, returning StreamingResponse instead of JSONResponse
  • Ollama's /api/embed sends application/json with chunked TE — so the OpenAI compat layer's isinstance(response, JSONResponse) guard in proxy_handler always failed
  • wrap_response was never called; callers got the raw Ollama-native shape {embeddings, model} instead of the OpenAI shape {object, data, model, usage}
  • Fix: remove transfer-encoding: chunked from the is_streaming heuristic — chunked TE is a transport mechanism, not an application-level streaming indicator. Streaming is identified solely by content-type (text/event-stream, application/x-ndjson)

Test plan

  • test_chunked_json_response_not_treated_as_streaming — new regression test
  • All 139 existing tests pass
  • Live verify after container rebuild: /v1/embeddings returns OpenAI-shaped response

Closes OQP-4

Generated with Claude Code

…I wrap (OQP-4)

Ollama's /api/embed sends application/json with transfer-encoding: chunked.
dispatch_request classified any chunked response as streaming, returning a
StreamingResponse. proxy_handler's isinstance(response, JSONResponse) guard
then failed, so wrap_response was never called and the Ollama-native body
passed through to callers expecting the OpenAI shape.

Fix: remove transfer-encoding: chunked from the is_streaming heuristic.
Chunked TE is a transport-layer mechanism; true streaming is identified by
content-type (text/event-stream, application/x-ndjson).

Adds regression test: test_chunked_json_response_not_treated_as_streaming.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

agent-id: developer
@TadMSTR TadMSTR merged commit 19cb0e8 into main Jun 23, 2026
4 checks passed
@TadMSTR TadMSTR deleted the fix/oqp-4-embeddings-openai-shape branch June 23, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant