Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,11 +28,17 @@ Always run the code at each step and repeat the steps if necessary until you rea
|
|
| 28 |
NEVER ASSUME, ALWAYS VERIFY!"""
|
| 29 |
|
| 30 |
|
| 31 |
-
def execute_jupyter_agent(sytem_prompt, user_input, max_new_tokens, model, message_history):
|
| 32 |
client = InferenceClient(api_key=HF_TOKEN)
|
| 33 |
#model = "meta-llama/Llama-3.1-8B-Instruct"
|
| 34 |
|
| 35 |
sbx = Sandbox(api_key=E2B_API_KEY)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Initialize message_history if it doesn't exist
|
| 38 |
if len(message_history)==0:
|
|
@@ -74,7 +80,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 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 |
-
gr.File(label="Upload files to use", file_count="multiple")
|
| 78 |
with gr.Row():
|
| 79 |
generate_btn = gr.Button("Let's go!")
|
| 80 |
clear_btn = gr.Button("Clear")
|
|
@@ -104,7 +110,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 104 |
|
| 105 |
generate_btn.click(
|
| 106 |
fn=execute_jupyter_agent,
|
| 107 |
-
inputs=[system_input, user_input, max_tokens, model, state],
|
| 108 |
outputs=[html_output, state]
|
| 109 |
)
|
| 110 |
|
|
|
|
| 28 |
NEVER ASSUME, ALWAYS VERIFY!"""
|
| 29 |
|
| 30 |
|
| 31 |
+
def execute_jupyter_agent(sytem_prompt, user_input, max_new_tokens, model,files, message_history):
|
| 32 |
client = InferenceClient(api_key=HF_TOKEN)
|
| 33 |
#model = "meta-llama/Llama-3.1-8B-Instruct"
|
| 34 |
|
| 35 |
sbx = Sandbox(api_key=E2B_API_KEY)
|
| 36 |
+
|
| 37 |
+
for filepath in files:
|
| 38 |
+
with open(filepath, "rb") as file:
|
| 39 |
+
print(f"uploading {filepath}...")
|
| 40 |
+
# Upload file to sandbox
|
| 41 |
+
sbx.files.write(filepath, file)
|
| 42 |
|
| 43 |
# Initialize message_history if it doesn't exist
|
| 44 |
if len(message_history)==0:
|
|
|
|
| 80 |
with gr.Row():
|
| 81 |
user_input = gr.Textbox(value="Solve the Lotka-Volterra equation and plot the results.", lines=3)
|
| 82 |
with gr.Row():
|
| 83 |
+
files = gr.File(label="Upload files to use", file_count="multiple")
|
| 84 |
with gr.Row():
|
| 85 |
generate_btn = gr.Button("Let's go!")
|
| 86 |
clear_btn = gr.Button("Clear")
|
|
|
|
| 110 |
|
| 111 |
generate_btn.click(
|
| 112 |
fn=execute_jupyter_agent,
|
| 113 |
+
inputs=[system_input, user_input, max_tokens, model, files, state],
|
| 114 |
outputs=[html_output, state]
|
| 115 |
)
|
| 116 |
|