Update app.py
Browse files
app.py
CHANGED
|
@@ -53,22 +53,20 @@ def generate_with_history(input_text, history):
|
|
| 53 |
|
| 54 |
# Building the Blocks interface
|
| 55 |
with gr.Blocks() as demo:
|
| 56 |
-
# State component
|
| 57 |
history_state = gr.State([])
|
| 58 |
|
| 59 |
-
#
|
| 60 |
-
input_box = gr.Textbox(visible=
|
| 61 |
-
output_box = gr.Markdown(visible=
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
# The API endpoint
|
| 64 |
-
# Note: We include history_state in both inputs and outputs
|
| 65 |
-
btn = gr.Button("Submit", visible=False)
|
| 66 |
btn.click(
|
| 67 |
fn=generate_with_history,
|
| 68 |
inputs=[input_box, history_state],
|
| 69 |
outputs=[output_box, history_state],
|
| 70 |
api_name="generate"
|
| 71 |
)
|
| 72 |
-
|
| 73 |
if __name__ == "__main__":
|
| 74 |
demo.launch()
|
|
|
|
| 53 |
|
| 54 |
# Building the Blocks interface
|
| 55 |
with gr.Blocks() as demo:
|
| 56 |
+
# State component (always invisible)
|
| 57 |
history_state = gr.State([])
|
| 58 |
|
| 59 |
+
# Change visible=False to True (or remove it)
|
| 60 |
+
input_box = gr.Textbox(label="Input", visible=True)
|
| 61 |
+
output_box = gr.Markdown(label="Response", visible=True)
|
| 62 |
+
|
| 63 |
+
btn = gr.Button("Submit", visible=True)
|
| 64 |
|
|
|
|
|
|
|
|
|
|
| 65 |
btn.click(
|
| 66 |
fn=generate_with_history,
|
| 67 |
inputs=[input_box, history_state],
|
| 68 |
outputs=[output_box, history_state],
|
| 69 |
api_name="generate"
|
| 70 |
)
|
|
|
|
| 71 |
if __name__ == "__main__":
|
| 72 |
demo.launch()
|