Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable request body OpenAPI spec for OpenAI endpoints #865

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

Peilun-Li
Copy link
Contributor

What & Why

FastAPI by default supports OpenAPI spec https://fastapi.tiangolo.com/tutorial/body/#automatic-docs which will be used to generate docs (e.g., Swagger UI). The way to enable request body documentation for post based endpoint is to include the custom data model into the function signature.

The way we use now request = ChatCompletionRequest(**await raw_request.json()), per https://fastapi.tiangolo.com/tutorial/body/#results , is essentially the same as defining as request: ChatCompletionRequest in the function signature. And the raw request usage won't be impacted per https://fastapi.tiangolo.com/advanced/using-request-directly/

The benefit of this change is to enable an interactive Swagger UI "Try it out" experience.

Without this change, the Swagger UI (the /docs endpoint of the server) shows no request body for the openai endpoint thus can't Try it out (Thus the Swagger UI is basically unusable)
Screenshot 2023-08-24 at 9 49 12 PM

With this change, the Swagger UI will show the request body and we can Try it out through the UI directly to hit the server.
Screenshot 2023-08-24 at 9 19 23 PM

This may help with many live demo use cases through the Swagger UI.

Copy link
Member

@zhuohan123 zhuohan123 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for your contribution!

@zhuohan123 zhuohan123 merged commit becd7a5 into vllm-project:main Aug 30, 2023
2 checks passed
hongxiayang pushed a commit to hongxiayang/vllm that referenced this pull request Feb 13, 2024
sjchoi1 pushed a commit to casys-kaist-internal/vllm that referenced this pull request May 7, 2024
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.

2 participants