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

Provide a better code snippet for generators in the "view API" page #4887

Closed
abidlabs opened this issue Jul 12, 2023 · 1 comment · Fixed by #5057
Closed

Provide a better code snippet for generators in the "view API" page #4887

abidlabs opened this issue Jul 12, 2023 · 1 comment · Fixed by #5057
Labels
docs/website Related to documentation or website enhancement New feature or request gradio_client Related to the one of the gradio client libraries

Comments

@abidlabs
Copy link
Member

Say you have a Gradio app like this:

import gradio as gr

def test(x):
    for i in range(len(x)):
        yield x[:i]

gr.Interface(test, "textbox", "textbox").queue().launch()

The view API page is still going to suggest that you use the .predict() function to call this method via an API:

image

However, this only gives you the first iteration, which is not usually what you want. Instead, it would be better to show the .submit() usage here.

Inspired by this question: https://discuss.huggingface.co/t/gradio-api-streaming/45395

@abidlabs abidlabs added enhancement New feature or request docs/website Related to documentation or website labels Jul 14, 2023
@freddyaboulton
Copy link
Collaborator

This should also be reflected in the view_api method of the clients! Inspired by this internal question where someone is using predict to stream text from a chatbot:

https://huggingface.slack.com/archives/C02QZLG8GMN/p1689585284045839

@freddyaboulton freddyaboulton added the gradio_client Related to the one of the gradio client libraries label Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs/website Related to documentation or website enhancement New feature or request gradio_client Related to the one of the gradio client libraries
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants