Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -46,6 +46,10 @@ def execute_jupyter_agent(sytem_prompt, user_input, max_new_tokens, model, messa
|
|
46 |
yield notebook_html, message_history
|
47 |
|
48 |
|
|
|
|
|
|
|
|
|
49 |
css = """
|
50 |
#component-0 {
|
51 |
height: 100vh;
|
@@ -65,11 +69,13 @@ css = """
|
|
65 |
|
66 |
# Create the interface
|
67 |
with gr.Blocks(css=css) as demo:
|
|
|
68 |
html_output = gr.HTML(value=update_notebook_display(create_base_notebook([])))
|
69 |
with gr.Row():
|
70 |
user_input = gr.Textbox(value="Solve the Lotka-Volterra equation and plot the results.", lines=3)
|
71 |
-
|
72 |
-
|
|
|
73 |
|
74 |
with gr.Accordion("Advanced Settings", open=False):
|
75 |
system_input = gr.Textbox(
|
@@ -94,8 +100,14 @@ with gr.Blocks(css=css) as demo:
|
|
94 |
|
95 |
generate_btn.click(
|
96 |
fn=execute_jupyter_agent,
|
97 |
-
inputs=[system_input, user_input, max_tokens, model,
|
98 |
-
outputs=[html_output,
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
)
|
100 |
|
101 |
demo.launch()
|
|
|
46 |
yield notebook_html, message_history
|
47 |
|
48 |
|
49 |
+
def clear(state):
|
50 |
+
state = []
|
51 |
+
return update_notebook_display(create_base_notebook([])), state
|
52 |
+
|
53 |
css = """
|
54 |
#component-0 {
|
55 |
height: 100vh;
|
|
|
69 |
|
70 |
# Create the interface
|
71 |
with gr.Blocks(css=css) as demo:
|
72 |
+
state = gr.State(value=[])
|
73 |
html_output = gr.HTML(value=update_notebook_display(create_base_notebook([])))
|
74 |
with gr.Row():
|
75 |
user_input = gr.Textbox(value="Solve the Lotka-Volterra equation and plot the results.", lines=3)
|
76 |
+
with gr.Row():
|
77 |
+
generate_btn = gr.Button("Let's go!")
|
78 |
+
clear_btn = gr.Button("Clear")
|
79 |
|
80 |
with gr.Accordion("Advanced Settings", open=False):
|
81 |
system_input = gr.Textbox(
|
|
|
100 |
|
101 |
generate_btn.click(
|
102 |
fn=execute_jupyter_agent,
|
103 |
+
inputs=[system_input, user_input, max_tokens, model, state)],
|
104 |
+
outputs=[html_output, state]
|
105 |
+
)
|
106 |
+
|
107 |
+
clear_btn.click(
|
108 |
+
fn=clear,
|
109 |
+
inputs=[state],
|
110 |
+
outputs=[html_output, state]
|
111 |
)
|
112 |
|
113 |
demo.launch()
|