Repository navigation
studio/openai: align chat completions docstring with stream=false default (closes #5047) - #5524
Conversation
…ault The schema and regression test for ChatCompletionRequest.stream were already corrected to default `false` (matching OpenAI's spec), but the route docstring still claimed streaming was the default -- misleading for anyone reading the source while debugging the original report. Updates the docstring to reflect the actual behavior, adds an explicit note pointing to unslothai#5047, and tags the existing regression test with the issue reference and the .NET / System.Text.Json client class so the intent survives future cleanup. Closes unslothai#5047
f4b396f to
4227091
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the documentation and test comments for the openai_chat_completions endpoint to reflect that non-streaming is now the default behavior, aligning with the OpenAI specification. Feedback suggests removing internal issue references from public-facing docstrings to keep API documentation clean and expanding test coverage to include route-level verification of the non-streaming response.
…I doc, add route-level test Two follow-ups on review feedback: - Drop "(see unslothai#5047)" from the openai_chat_completions docstring so the internal issue number doesn't leak into the FastAPI-generated OpenAPI / Swagger schema. The reference now lives in a code comment next to the actual `if payload.stream:` branch, where it's most useful for the next person debugging the same class of report. - Add test_post_without_stream_field_decodes_to_stream_false_over_http: a TestClient-based wire-level guard that POSTs a body without `stream` (the exact shape naive curl / .NET / System.Text.Json clients send) and asserts both that the request deserialises into stream=False *and* that the response Content-Type is application/json, never text/event-stream. The existing constructor-level test would silently miss regressions introduced by middleware or alias rewrites that mutate the body before the pydantic model is built. Refs unslothai#5047
|
Addressed review feedback:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f684baebd5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 253b27ec89
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Summary
POST /v1/chat/completions's docstring still says "Streaming (default)", but the schema and the existing pydantic regression test were already corrected soChatCompletionRequest.streamdefaults tofalse(matching OpenAI's spec). The stale docstring is the last loose end on #5047 — anyone debugging the original .NET /System.Text.Jsonreport and grepping the route would still come away thinking SSE is the default behavior.Two tiny changes, no logic touched:
studio/backend/routes/inference.py— flip the two-line block inopenai_chat_completions' docstring to listNon-streaming (default)first and add a one-line note pointing to [Bug]/v1/chat/completionsdefaults to streaming whenstreamis omitted #5047.studio/backend/tests/test_openai_tool_passthrough.py— extend the comment ontest_stream_defaults_false_matching_openai_specto mention the.NET / System.Text.Jsonfailure mode from [Bug]/v1/chat/completionsdefaults to streaming whenstreamis omitted #5047, so the test's intent stays discoverable.Why this is the right scope
I checked all three OpenAI-compat schemas —
ChatCompletionRequest,AnthropicMessagesRequest,ResponsesRequest— and all three already pinstreamtoFalsewith matching tests intest_openai_tool_passthrough.py:299,test_anthropic_messages.py:89, andtest_responses_api.py:91. Confirmed via grep + reading; nothing else to change.I also checked
routes/inference.pyfor other staleStreaming (default)mentions — there's only the one at line 1962. The Anthropic Messages and Responses route docstrings are neutrally worded.Test plan
ruff check— clean on both filesscripts/enforce_kwargs_spacing.py— clean (no kwarg lines touched; only docstring + comment)python3 -m astparse — both files import cleanlypytest studio/backend/tests/test_openai_tool_passthrough.pyin CIHappy to extend if you'd like an
httpx.AsyncClientintegration test that hits the route with thestreamfield omitted and asserts JSON (vs. SSE) — wasn't sure if the existing schema-level pin felt sufficient. Defer to your call.