Closed abidlabs closed 4 weeks ago
• | Name | Status | URL |
---|---|---|---|
Spaces | Spaces preview | ||
Website | Website preview | ||
:unicorn: | Changes | Details |
Install Gradio from this PR
pip install https://gradio-builds.s3.amazonaws.com/e686632a341e5789eb5cf482e2199c7a29dd8f2b/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@e686632a341e5789eb5cf482e2199c7a29dd8f2b#subdirectory=client/python"
Install Gradio JS Client from this PR
npm install https://gradio-builds.s3.amazonaws.com/e686632a341e5789eb5cf482e2199c7a29dd8f2b/gradio-client-0.20.1.tgz
Package | Version |
---|---|
gradio |
patch |
Handle special arguments when extracting parameter names for view API page
Maintainers or the PR author can modify the PR title to modify this entry.
Can we use something like functools.wraps in the chat_interface case to preserve the original signature?
Also, I was wondering why we need to construct the special args within the chat_interface function. Shouldn't that be handled by the regular request life-cycle in Blocks.
Can we use something like functools.wraps in the chat_interface case to preserve the original signature?
I think so yes I'll take a look
Also, I was wondering why we need to construct the special args within the chat_interface function. Shouldn't that be handled by the regular request life-cycle in Blocks.
Sorry what are you referring to by this?
Sorry what are you referring to by this?
If we can use something like functools.wraps
to preserve the original signature, then I don't think we need to call special_args
within submit_fn
because gr.Blocks
will know to pass the request as an input if it sees the type hint.
Thanks @freddyaboulton for the suggestion. Refactored to use functools.wraps
, so now we handle gr.ChatInterface
with additional parameters correctly as well. For the example in the original issue, we now have:
Indeed. Thanks @freddyaboulton for the reviews and suggestions.
Closes: https://github.com/gradio-app/gradio/issues/8399
Test with:
For the case of
gr.ChatInterface
, we can't get the original parameter names because we construct a wrapper function over the user's defined function, so in such cases, the parameter names are generated automatically: