Skip to content

docs: enhance send-chat-message docs to also show ChatFullResponse#7430

Merged
jmelahman merged 3 commits intoonyx-dot-app:mainfrom
ciaransweet:enhance-send-chat-message-docs
Jan 22, 2026
Merged

docs: enhance send-chat-message docs to also show ChatFullResponse#7430
jmelahman merged 3 commits intoonyx-dot-app:mainfrom
ciaransweet:enhance-send-chat-message-docs

Conversation

@ciaransweet
Copy link
Copy Markdown
Contributor

@ciaransweet ciaransweet commented Jan 15, 2026

Description

When developing integrations with the new send-chat-message endpoint, I noticed that currently, the Swagger docs only display the stream example ("string") whereas it can return a StreamingResponse or a ChatFullResponse when stream=false - It'd be useful to have this model in the docs for clarity.

I updated the responses field in the method definition to include both examples, for stream and not.

How Has This Been Tested?

  • Fresh clone of repo
  • Stood up services following CONTRIBUTING_VSCODE.md
  • Found: <api-url>/docs#/public/handle_send_chat_message
  • Identified missing examples:
image
  • Made changes to method definition
  • Observed updated examples:
image image

Additional Options

  • [Optional] Override Linear Check

@ciaransweet ciaransweet requested a review from a team as a code owner January 15, 2026 14:32
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 15, 2026

Greptile Summary

This PR enhances the Swagger/OpenAPI documentation for the /send-chat-message endpoint by adding explicit response models for both streaming and non-streaming modes. Previously, the docs only showed the streaming response (text/event-stream) example. Now they include both the streaming response and the ChatFullResponse schema for when stream=false, providing clearer API guidance for developers integrating with the endpoint.

The changes are purely documentation-focused:

  • Added response_class=StreamingResponse parameter to indicate the default response type
  • Added comprehensive responses parameter to the @router.post() decorator that documents both response modes
  • Included schema reference to ChatFullResponse.model_json_schema() for non-streaming responses
  • Clarified in the description when each response type is returned based on the stream parameter

Confidence Score: 5/5

  • This PR is safe to merge with no concerns - it's a pure documentation improvement with zero impact on runtime behavior.
  • This is a documentation-only change with zero risk. The modification adds OpenAPI/Swagger response documentation to clarify the two possible response modes (streaming vs non-streaming). The ChatFullResponse model is already fully imported and properly defined. The changes align with FastAPI best practices for documenting conditional response types and provide valuable clarity for API consumers without introducing any functional changes to the endpoint logic.
  • No files require special attention - the change is straightforward and well-scoped.

Important Files Changed

Filename Overview
backend/onyx/server/query_and_chat/chat_backend.py Enhanced /send-chat-message OpenAPI documentation by adding explicit response models for both streaming and non-streaming modes. The endpoint now shows ChatFullResponse schema in Swagger docs when stream=false, improving API clarity for integrators. Changes are purely documentation-focused with no logic modifications.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Endpoint as /send-chat-message
    participant Logic as Message Processing
    participant Response
    
    Note over Client,Response: stream=true (default)
    Client->>Endpoint: POST with stream=true
    Endpoint->>Logic: Handle stream mode
    Logic-->>Endpoint: Packet stream
    Endpoint-->>Response: StreamingResponse (text/event-stream)
    Response-->>Client: SSE stream of packets
    
    Note over Client,Response: stream=false
    Client->>Endpoint: POST with stream=false
    Endpoint->>Logic: Handle non-stream mode
    Logic-->>Endpoint: Collect all packets
    Endpoint-->>Response: ChatFullResponse (application/json)
    Response-->>Client: Complete JSON response
Loading

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 15, 2026

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="backend/onyx/server/query_and_chat/chat_backend.py">

<violation number="1" location="backend/onyx/server/query_and_chat/chat_backend.py:536">
P2: Non-streaming chat response is wrapped in StreamingResponse due to response_class override, breaking JSON ChatFullResponse for stream=false</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@ciaransweet ciaransweet force-pushed the enhance-send-chat-message-docs branch from 99c5de3 to 4944c11 Compare January 19, 2026 10:23
@ciaransweet
Copy link
Copy Markdown
Contributor Author

@yuhongsun96 @wenxi-onyx is there anything I can do for this?

@ciaransweet ciaransweet force-pushed the enhance-send-chat-message-docs branch from 4944c11 to 5dc5942 Compare January 21, 2026 08:23
@jmelahman
Copy link
Copy Markdown
Contributor

@yuhongsun96 @wenxi-onyx is there anything I can do for this?

The test failures seem real and being introduced by this change. You can reproduce them locally by running,

$ uv run --with onyx-devtools ods openapi all

which is a shorthand for,

$ source .venv/bin/activate
$ PYTHONPATH=backend python backend/scripts/onyx_openapi_schema.py --filename backend/generated/openapi.json
$ openapi-generator-cli generate -i backend/generated/openapi.json -g python -o backend/generated/onyx_openapi_client --package-name onyx_openapi_client --skip-validate-spec --openapi-normalizer "SIMPLIFY_ONEOF_ANYOF=true,SET_OAS3_NULLABLE=true"

@ciaransweet
Copy link
Copy Markdown
Contributor Author

@yuhongsun96 @wenxi-onyx is there anything I can do for this?

The test failures seem real and being introduced by this change. You can reproduce them locally by running,

$ uv run --with onyx-devtools ods openapi all

which is a shorthand for,

$ source .venv/bin/activate
$ PYTHONPATH=backend python backend/scripts/onyx_openapi_schema.py --filename backend/generated/openapi.json
$ openapi-generator-cli generate -i backend/generated/openapi.json -g python -o backend/generated/onyx_openapi_client --package-name onyx_openapi_client --skip-validate-spec --openapi-normalizer "SIMPLIFY_ONEOF_ANYOF=true,SET_OAS3_NULLABLE=true"

Could you point out which test case(s) are failing?

Struggling to read the output of that command.

@ciaransweet
Copy link
Copy Markdown
Contributor Author

ciaransweet commented Jan 21, 2026

For what it's worth, the command fails for me on main at d8068f0a682b5b0134d98d65541162e161c5c998...

INFO Generating OpenAPI schema and Python client  
INFO Schema output: /Users/ciaran/dev/onyx/backend/generated/openapi.json 
INFO Client output: /Users/ciaran/dev/onyx/backend/generated/onyx_openapi_client 
Traceback (most recent call last):
  File "<stdin>", line 236, in <module>
  File "<stdin>", line 225, in main
  File "<stdin>", line 36, in generate_schema
  File "/Users/ciaran/dev/onyx/backend/onyx/main.py", line 52, in <module>
    from onyx.server.auth_check import check_router_auth
  File "/Users/ciaran/dev/onyx/backend/onyx/server/auth_check.py", line 14, in <module>
    from onyx.server.onyx_api.ingestion import api_key_dep
  File "/Users/ciaran/dev/onyx/backend/onyx/server/onyx_api/ingestion.py", line 21, in <module>
    from onyx.indexing.indexing_pipeline import build_indexing_pipeline
  File "/Users/ciaran/dev/onyx/backend/onyx/indexing/indexing_pipeline.py", line 72, in <module>
    from onyx.llm.chat_llm import LLMRateLimitError
  File "/Users/ciaran/dev/onyx/backend/onyx/llm/chat_llm.py", line 39, in <module>
    from onyx.llm.llm_provider_options import CREDENTIALS_FILE_CUSTOM_CONFIG_KEY
  File "/Users/ciaran/dev/onyx/backend/onyx/llm/llm_provider_options.py", line 82, in <module>
    for model in litellm.bedrock_models + litellm.bedrock_converse_models
                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'set' and 'set'
CRITICAL: Exiting due to uncaught exception TypeError: unsupported operand type(s) for +: 'set' and 'set'
FATA Failed to generate OpenAPI schema and client: exit status 1 

@jmelahman
Copy link
Copy Markdown
Contributor

For what it's worth, the command fails for me on main at d8068f0a682b5b0134d98d65541162e161c5c998...

INFO Generating OpenAPI schema and Python client  
INFO Schema output: /Users/ciaran/dev/onyx/backend/generated/openapi.json 
INFO Client output: /Users/ciaran/dev/onyx/backend/generated/onyx_openapi_client 
Traceback (most recent call last):
  File "<stdin>", line 236, in <module>
  File "<stdin>", line 225, in main
  File "<stdin>", line 36, in generate_schema
  File "/Users/ciaran/dev/onyx/backend/onyx/main.py", line 52, in <module>
    from onyx.server.auth_check import check_router_auth
  File "/Users/ciaran/dev/onyx/backend/onyx/server/auth_check.py", line 14, in <module>
    from onyx.server.onyx_api.ingestion import api_key_dep
  File "/Users/ciaran/dev/onyx/backend/onyx/server/onyx_api/ingestion.py", line 21, in <module>
    from onyx.indexing.indexing_pipeline import build_indexing_pipeline
  File "/Users/ciaran/dev/onyx/backend/onyx/indexing/indexing_pipeline.py", line 72, in <module>
    from onyx.llm.chat_llm import LLMRateLimitError
  File "/Users/ciaran/dev/onyx/backend/onyx/llm/chat_llm.py", line 39, in <module>
    from onyx.llm.llm_provider_options import CREDENTIALS_FILE_CUSTOM_CONFIG_KEY
  File "/Users/ciaran/dev/onyx/backend/onyx/llm/llm_provider_options.py", line 82, in <module>
    for model in litellm.bedrock_models + litellm.bedrock_converse_models
                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'set' and 'set'
CRITICAL: Exiting due to uncaught exception TypeError: unsupported operand type(s) for +: 'set' and 'set'
FATA Failed to generate OpenAPI schema and client: exit status 1 

Hmmm. d8068f0a682b5b0134d98d65541162e161c5c998 is from 8 months ago.

That looks like a python version incompatibility (if not actually broken code). We primarily test and develop on python3.11. uv also makes it convenient to setup a specific python toolchain, https://github.com/onyx-dot-app/onyx/blob/main/contributing_guides/dev_setup.md#local-set-up

@ciaransweet
Copy link
Copy Markdown
Contributor Author

ciaransweet commented Jan 21, 2026 via email

@ciaransweet ciaransweet force-pushed the enhance-send-chat-message-docs branch from 5dc5942 to a0c37fc Compare January 22, 2026 11:02
@ciaransweet
Copy link
Copy Markdown
Contributor Author

Hey @jmelahman sorry for the tired responses last night! I dived back in this morning and have resolved the failing spec generation 🙌

@jmelahman jmelahman enabled auto-merge January 22, 2026 16:38
@jmelahman jmelahman added this pull request to the merge queue Jan 22, 2026
Merged via the queue into onyx-dot-app:main with commit e4bdb15 Jan 22, 2026
76 of 78 checks passed
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.

4 participants