Remove usage of deprecated gr.inputs and gr.outputs from website#1796
Conversation
| return history, history | ||
|
|
||
|
|
||
| state = gr.Variable(value=[]) |
There was a problem hiding this comment.
using "state" is technically deprecated so I'm using gr.Variable here.
It makes the demo more verbose but it's more aligned with our current api. What do people think? Also had to modify the chatbot and real-time speech recognition guides.
There was a problem hiding this comment.
Actually I think "state" shortcut is not deprecated in Interfaces. Is this demo not working for you as is @freddyaboulton? Because I just tested it on my end and it is working for me!
cc @aliabid94 as well
| Another type of data persistence Gradio supports is session **state**, where data persists across multiple submits within a page load. However, data is *not* shared between different users of your model. To store data in a session state, you need to do three things: (1) Pass in an extra parameter into your function, which represents the state of the interface. (2) At the end of the function, return the updated value of the state as an extra return value (3) Add the `'state'` input and `'state'` output components when creating your `Interface`. See the chatbot example below: | ||
| Another type of data persistence Gradio supports is session **state**, where data persists across multiple submits within a page load. However, data is *not* shared between different users of your model. To store data in a session state, you need to do three things: | ||
|
|
||
| 1. Pass in an extra parameter into your function, which represents the state of the interface. |
|
|
||
| ```python | ||
| def predict(input, history=[]): | ||
| def predict(input, history): |
There was a problem hiding this comment.
I think we need this to set the original value of the state
|
|
||
| 1. Pass in an extra parameter into your function, which represents the state of the interface. | ||
| 2. At the end of the function, return the updated value of the state as an extra return value. | ||
| 3. Create a `gr.Variable` and pass it as an input and output component of the `Interface`. |
There was a problem hiding this comment.
Let's resolve the issue about the string shortcut. I think it is an acceptable approach within Interface.
We've deprected "gr.State" but the "state" shortcut should still work, it just maps to "gr.Variable" instead
There was a problem hiding this comment.
I'll back out the changes related to the "state" string shortcut!
Much simpler to use and if it's not deprecated no need to remove it from the docs. Thank you
|
|
||
|
|
||
| state = gr.Variable(value=[]) | ||
| chatbot = gr.Chatbot(color_map=("green", "pink")).style() |
There was a problem hiding this comment.
On the other hand, color_map is not part of the constructor for gr.Chatbot, it's been moved to style()
There was a problem hiding this comment.
Great point!
|
Great, thanks for the fix @freddyaboulton! Have some considerations around "state" and whether we should really deprecate it, but otherwise LGTM. cc @aliabid94 |
55a6b00 to
a7cdc4f
Compare
|
Thanks for the review @abidlabs ! Should be good for another look now - removed all the changes related to the "state" string shortcut. |
omerXfaruq
left a comment
There was a problem hiding this comment.
Thanks for removing deprecated parts from the codebase :)
b8bece2 to
2ad985a
Compare

Description
Fixes #1786
Mainly just deleted usage of
gr.inputsandgr.ouputsbut also got rid of usage of the "state" shortcut.Checklist: