Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,9 +29,8 @@ Always run the code at each step and repeat the steps if necessary until you rea
|
|
29 |
NEVER ASSUME, ALWAYS VERIFY!"""
|
30 |
|
31 |
|
32 |
-
def execute_jupyter_agent(sytem_prompt, user_input):
|
33 |
client = InferenceClient(api_key=HF_TOKEN)
|
34 |
-
max_new_tokens = 512
|
35 |
model = "meta-llama/Llama-3.1-8B-Instruct"
|
36 |
|
37 |
sbx = Sandbox(api_key=E2B_API_KEY)
|
@@ -41,7 +40,7 @@ def execute_jupyter_agent(sytem_prompt, user_input):
|
|
41 |
{"role": "user", "content": user_input}
|
42 |
]
|
43 |
|
44 |
-
for notebook_html, messages in run_interactive_notebook(client, model, messages, sbx):
|
45 |
message_history = messages
|
46 |
yield notebook_html
|
47 |
|
@@ -65,18 +64,34 @@ css = """
|
|
65 |
|
66 |
# Create the interface
|
67 |
with gr.Blocks(css=css) as demo:
|
68 |
-
gr.Markdown("#
|
69 |
|
70 |
with gr.Row():
|
71 |
-
system_input = gr.Textbox(label="System prompt", value=DEFAULT_SYSTEM_PROMPT)
|
72 |
user_input = gr.Textbox(label="User prompt", placeholder="Solve the Lotka-Volterra equation and plot the results.", lines=3)
|
73 |
|
74 |
generate_btn = gr.Button("Let's go!")
|
75 |
output = gr.HTML(label="Jupyter Notebook")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
generate_btn.click(
|
78 |
fn=execute_jupyter_agent,
|
79 |
-
inputs=[system_input, user_input],
|
80 |
outputs=output
|
81 |
)
|
82 |
|
|
|
29 |
NEVER ASSUME, ALWAYS VERIFY!"""
|
30 |
|
31 |
|
32 |
+
def execute_jupyter_agent(sytem_prompt, user_input, max_tokens):
|
33 |
client = InferenceClient(api_key=HF_TOKEN)
|
|
|
34 |
model = "meta-llama/Llama-3.1-8B-Instruct"
|
35 |
|
36 |
sbx = Sandbox(api_key=E2B_API_KEY)
|
|
|
40 |
{"role": "user", "content": user_input}
|
41 |
]
|
42 |
|
43 |
+
for notebook_html, messages in run_interactive_notebook(client, model, messages, sbx, max_tokens):
|
44 |
message_history = messages
|
45 |
yield notebook_html
|
46 |
|
|
|
64 |
|
65 |
# Create the interface
|
66 |
with gr.Blocks(css=css) as demo:
|
67 |
+
gr.Markdown("# Jupyter Agent!")
|
68 |
|
69 |
with gr.Row():
|
|
|
70 |
user_input = gr.Textbox(label="User prompt", placeholder="Solve the Lotka-Volterra equation and plot the results.", lines=3)
|
71 |
|
72 |
generate_btn = gr.Button("Let's go!")
|
73 |
output = gr.HTML(label="Jupyter Notebook")
|
74 |
+
|
75 |
+
with gr.Accordion("Advanced Settings", open=False):
|
76 |
+
system_input = gr.Textbox(
|
77 |
+
label="System Prompt",
|
78 |
+
value=DEFAULT_SYSTEM_PROMPT,
|
79 |
+
lines=4,
|
80 |
+
elem_classes="input-box"
|
81 |
+
)
|
82 |
+
|
83 |
+
max_tokens = gr.Number(
|
84 |
+
label="Max New Tokens",
|
85 |
+
value=DEFAULT_MAX_TOKENS,
|
86 |
+
minimum=128,
|
87 |
+
maximum=2048,
|
88 |
+
step=8,
|
89 |
+
interactive=False
|
90 |
+
)
|
91 |
|
92 |
generate_btn.click(
|
93 |
fn=execute_jupyter_agent,
|
94 |
+
inputs=[system_input, user_input, max_tokens],
|
95 |
outputs=output
|
96 |
)
|
97 |
|