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

OpenAPI docs not working #7287

Closed
1 task done
jpaquim opened this issue Feb 2, 2024 · 3 comments · Fixed by #8530
Closed
1 task done

OpenAPI docs not working #7287

jpaquim opened this issue Feb 2, 2024 · 3 comments · Fixed by #8530
Labels
bug Something isn't working

Comments

@jpaquim
Copy link

jpaquim commented Feb 2, 2024

Describe the bug

Getting this error when trying to get the API docs as described in this comment: pydantic.errors.PydanticInvalidForJsonSchema: Cannot generate a JsonSchema for core_schema.IsInstanceSchema (<class 'starlette.requests.Request'>)

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr


def greet(name, intensity):
    return "Hello " * intensity + name + "!"


demo = gr.Interface(fn=greet, inputs=["text", "slider"], outputs=["text"])

demo.launch(app_kwargs={"docs_url": "/docs"})

Screenshot

No response

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Darwin
gradio version: 4.16.0
gradio_client version: 0.8.1

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.2.0
fastapi: 0.109.0
ffmpy: 0.3.1
gradio-client==0.8.1 is not installed.
httpx: 0.26.0
huggingface-hub: 0.20.3
importlib-resources: 6.1.1
jinja2: 3.1.3
markupsafe: 2.1.5
matplotlib: 3.8.2
numpy: 1.26.3
orjson: 3.9.12
packaging: 23.2
pandas: 2.2.0
pillow: 10.2.0
pydantic: 2.6.0
pydub: 0.25.1
python-multipart: 0.0.6
pyyaml: 6.0.1
ruff: 0.2.0
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.9.0
typing-extensions: 4.9.0
uvicorn: 0.27.0.post1
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2023.12.2
httpx: 0.26.0
huggingface-hub: 0.20.3
packaging: 23.2
typing-extensions: 4.9.0
websockets: 11.0.3

Severity

I can work around it

@jpaquim jpaquim added the bug Something isn't working label Feb 2, 2024
@abidlabs
Copy link
Member

abidlabs commented Feb 2, 2024

We currently don't support this as (due to changes in Gradio 4.0), as its pretty hard to use the API endpoints directly. The ideal way is to use the Python or JS clients, which expose the API endpoint information both programmatically and in human-readable formats. https://www.gradio.app/guides/getting-started-with-the-python-client#inspecting-the-api-endpoints

That being said, I know in some cases it'd be nice to have the OpenAPI docs, we're discussing the best way to do this, please follow this existing issue for updates: #672

@abidlabs abidlabs closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
@jpaquim
Copy link
Author

jpaquim commented Feb 5, 2024

@abidlabs I understand your reasoning for pushing the Python and JS clients, but having a standard HTTP API is really valuable and in particular allows for the use of any language client without needing dedicated maintenance on your side. For me in particular, it doesn't help that the JS client is currently broken on Node.js, and with the lack of documentation on the Gradio API endpoints, I'm forced to implement separate dedicated FastAPI endpoints exposing essentially the same functionality in order to be able to access it with a regular fetch call from Node.js.

@abidlabs
Copy link
Member

abidlabs commented Feb 5, 2024

Totally agree @jpaquim, it's quite a bummer that the JS client is broken (we are working on fixing this right now cc @pngwn @hannahblair).

We will also release regular HTTP APIs soon but its going to take longer since we have to develop a way to query the endpoints that is much friendlier to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants