gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.56k stars 2.27k forks source link

Fix request serialization for fastapi `/docs` #8530

Closed zhzLuke96 closed 2 weeks ago

zhzLuke96 commented 2 weeks ago

This commit addresses a serialization issue in the PredictBody model that has been present since version 4.0. The request attribute, being of type Request, could not be serialized automatically, affecting FastAPI's auto-generated documentation (/openapi.json). By adding a custom __get_pydantic_json_schema__ method, the serialization schema is manually defined, ensuring correct documentation generation. This is also one of the reasons why applications like "stable-diffusion-webui," which require /docs pages, have not updated to newer versions of Gradio.

Closes: #7287

gradio-pr-bot commented 2 weeks ago

🪼 branch checks and previews

• Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
:unicorn: Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/c841ac8484eb4d18ef185ee583c75f4a6ff73b1e/gradio-4.36.1-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@c841ac8484eb4d18ef185ee583c75f4a6ff73b1e#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/c841ac8484eb4d18ef185ee583c75f4a6ff73b1e/gradio-client-1.1.1.tgz
gradio-pr-bot commented 2 weeks ago

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch

With the following changelog entry.

Fix request serialization for fastapi /docs

Maintainers or the PR author can modify the PR title to modify this entry.

#### Something isn't right? - Maintainers can change the version label to modify the version bump. - If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can [update the changelog file directly](https://github.com/zhzLuke96/gradio/edit/main/.changeset/dull-lizards-suffer.md).