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

Feature request: API Introspection #2364

Closed
leszekhanusz opened this issue Sep 28, 2022 · 6 comments · Fixed by #3663
Closed

Feature request: API Introspection #2364

leszekhanusz opened this issue Sep 28, 2022 · 6 comments · Fixed by #3663
Labels
enhancement New feature or request

Comments

@leszekhanusz
Copy link

Making an external frontend integrating with a gradio interface using the API can be really difficult if the gradio API is constantly changing.

Please provide a way to detect the inputs and outputs of a gradio API (it's too bad the interface is not made using GraphQL or we would be able to use introspection)

Context: I'm currently writing a GUI for a gradio interface and the gradio interface is constantly changing, breaking the API in the process.
I would like to programmatically send a request to the API to detect the different functions, fn_id, inputs and outputs of the interface, the default input values, min, max, type of input, etc...

@freddyaboulton
Copy link
Collaborator

Hi @leszekhanusz !

Is the api page at the bottom of the gradio front end in line with what you expect?

image

If pass the api_name parameter when you define your events, you will see the api route docs

image

@leszekhanusz
Copy link
Author

leszekhanusz commented Sep 28, 2022

Yes, but I want to access it programmatically, meaning I'd do another request and receive this info in a nice json form that could be exploited by a program, not html

@leszekhanusz
Copy link
Author

I've looked into this a bit more and in fact this already exists!
All the info is there in the /config path!

This should definitely get a mention in the docs!

@pngwn
Copy link
Member

pngwn commented Sep 30, 2022

Two interesting points here:

  • We could make introspection of this kind simpler and surface it better in the docs.
  • We should stop breaking the API.

The API does go through a little churn atm, I do think we want to stabilise that in the future but I don't think we'll be able to do that until we make some more breaking changes (which we try to minimise). This will probably require a major version bump, so we can overhaul the signatures to be more robust to future changes.

The first point is something we can definitely do.

I'd like to leave this issue open so this concern doesn't fall off our radar but I'll open a new issue to document this feature (and maybe) clean up the API before we make it public.

@pngwn pngwn mentioned this issue Sep 30, 2022
1 task
@abidlabs abidlabs added the docs/website Related to documentation or website label Oct 5, 2022
@aliabd aliabd added this to the website-priority milestone Oct 5, 2022
@aliabd aliabd self-assigned this Oct 24, 2022
@abidlabs abidlabs assigned aliabid94 and unassigned aliabd Nov 21, 2022
@aliabd aliabd removed the docs/website Related to documentation or website label Nov 21, 2022
@aliabd aliabd removed this from the website-priority milestone Nov 21, 2022
@abidlabs abidlabs added this to the Gradio as an API milestone Feb 9, 2023
@abidlabs
Copy link
Member

abidlabs commented Mar 6, 2023

Once we have programmatic introspection, let's disable the FastAPI /docs route. It adds no additional value and is kind of confusing since it exposes so many routes that users should not be using:

image

@freddyaboulton
Copy link
Collaborator

Yes makes sense @abidlabs !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants