Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def greet(inp):
|
|
|
|
|
4 |
return "Hello " + inp + "!"
|
5 |
|
6 |
with gr.Blocks() as demo:
|
|
|
7 |
with gr.Row():
|
8 |
with gr.Column(scale=2):
|
9 |
text1 = gr.Textbox(lines=7, label="Prompt", scale=2)
|
@@ -13,6 +16,6 @@ with gr.Blocks() as demo:
|
|
13 |
btn3 = gr.Button("Clean Memory", scale=2)
|
14 |
with gr.Column(scale=2):
|
15 |
out_text = gr.Text(lines=15, label="Output", scale=2)
|
16 |
-
btn1.click(fn=greet, inputs=text1, outputs=out_text)
|
17 |
btn2.click(lambda: [None, None], outputs=[text1, out_text])
|
18 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def greet(inp, messages):
|
4 |
+
messages.append(inp)
|
5 |
+
print(messages)
|
6 |
return "Hello " + inp + "!"
|
7 |
|
8 |
with gr.Blocks() as demo:
|
9 |
+
stored_message = gr.State([])
|
10 |
with gr.Row():
|
11 |
with gr.Column(scale=2):
|
12 |
text1 = gr.Textbox(lines=7, label="Prompt", scale=2)
|
|
|
16 |
btn3 = gr.Button("Clean Memory", scale=2)
|
17 |
with gr.Column(scale=2):
|
18 |
out_text = gr.Text(lines=15, label="Output", scale=2)
|
19 |
+
btn1.click(fn=greet, inputs=[text1, stored_message], outputs=out_text)
|
20 |
btn2.click(lambda: [None, None], outputs=[text1, out_text])
|
21 |
demo.launch()
|