-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Handle gradio apps using state
in the JS Client
#8439
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/e575ab2b553567abf55d922993d4e01d9b0deeca/gradio-4.32.2-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@e575ab2b553567abf55d922993d4e01d9b0deeca#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-builds.s3.amazonaws.com/e575ab2b553567abf55d922993d4e01d9b0deeca/gradio-client-0.20.1.tgz |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
Thanks @hannahblair! We should also make sure to remove any output values that correspond to a For example, here: import gradio as gr
gr.ChatInterface(lambda x,y:x).launch() The docs state that the When I ran this code: import { Client } from "@gradio/client";
const app = await Client.connect("http://127.0.0.1:7860/");
const result = await app.predict("/chat", {
message: "Hello!!",
});
console.log(result.data); the function did indeed accept a single input, but it also returned a null value corresponding to the state output component that should not be there:
It should just return As a side note, I needed to do:
not
otherwise I see this error:
|
Looks like the recent changes caused some failures. Will review again when they are passing. |
problems
solutions
|
state
in the JS Clientstate
in the JS Client
@@ -274,7 +274,8 @@ | |||
: host || space || src || location.origin; | |||
|
|||
app = await Client.connect(api_url, { | |||
status_callback: handle_status | |||
status_callback: handle_status, | |||
with_null_state: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this one on @hannahblair! If you are happy, I'm happy.
thanks so much @pngwn! interesting to know that we needed those values in internally. i've tested and all looks good |
Description
We were receiving a param error when a space was using state. This PR adds logic to send
null
for eachstate
param in the API, allowing us to receive the expected data.Closes: #5120
👻 Note, I haven't added a test for this because we still haven't got tests in place for
submit
andpredict
, which are TBD. I'm not sure where would be worth adding a test until we have those relevant tests.🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh