Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,14 +30,14 @@ with open("ds-system-prompt.txt", "r") as f:
|
|
| 30 |
|
| 31 |
|
| 32 |
def execute_jupyter_agent(
|
| 33 |
-
sytem_prompt, user_input, max_new_tokens, model, files, message_history
|
| 34 |
):
|
| 35 |
client = InferenceClient(api_key=HF_TOKEN)
|
| 36 |
|
| 37 |
tokenizer = AutoTokenizer.from_pretrained(model)
|
| 38 |
# model = "meta-llama/Llama-3.1-8B-Instruct"
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
filenames = []
|
| 43 |
if files is not None:
|
|
@@ -67,9 +67,11 @@ def execute_jupyter_agent(
|
|
| 67 |
yield notebook_html, message_history
|
| 68 |
|
| 69 |
|
| 70 |
-
def clear(
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
css = """
|
|
@@ -91,7 +93,8 @@ css = """
|
|
| 91 |
|
| 92 |
# Create the interface
|
| 93 |
with gr.Blocks() as demo:
|
| 94 |
-
|
|
|
|
| 95 |
|
| 96 |
html_output = gr.HTML(value=update_notebook_display(create_base_notebook([])[0]))
|
| 97 |
|
|
@@ -134,11 +137,11 @@ with gr.Blocks() as demo:
|
|
| 134 |
|
| 135 |
generate_btn.click(
|
| 136 |
fn=execute_jupyter_agent,
|
| 137 |
-
inputs=[system_input, user_input, max_tokens, model, files,
|
| 138 |
-
outputs=[html_output,
|
| 139 |
)
|
| 140 |
|
| 141 |
-
clear_btn.click(fn=clear, inputs=[
|
| 142 |
|
| 143 |
demo.load(
|
| 144 |
fn=None,
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
def execute_jupyter_agent(
|
| 33 |
+
sytem_prompt, user_input, max_new_tokens, model, files, message_history, sbx
|
| 34 |
):
|
| 35 |
client = InferenceClient(api_key=HF_TOKEN)
|
| 36 |
|
| 37 |
tokenizer = AutoTokenizer.from_pretrained(model)
|
| 38 |
# model = "meta-llama/Llama-3.1-8B-Instruct"
|
| 39 |
|
| 40 |
+
|
| 41 |
|
| 42 |
filenames = []
|
| 43 |
if files is not None:
|
|
|
|
| 67 |
yield notebook_html, message_history
|
| 68 |
|
| 69 |
|
| 70 |
+
def clear(msg_state, sbx_state):
|
| 71 |
+
msg_state = []
|
| 72 |
+
sbx_state.kill()
|
| 73 |
+
sbx_state = Sandbox(api_key=E2B_API_KEY)
|
| 74 |
+
return update_notebook_display(create_base_notebook([])[0]), msg_state, sbx_state
|
| 75 |
|
| 76 |
|
| 77 |
css = """
|
|
|
|
| 93 |
|
| 94 |
# Create the interface
|
| 95 |
with gr.Blocks() as demo:
|
| 96 |
+
msg_state = gr.State(value=[])
|
| 97 |
+
sbx_state = gr.State(value=Sandbox(api_key=E2B_API_KEY))
|
| 98 |
|
| 99 |
html_output = gr.HTML(value=update_notebook_display(create_base_notebook([])[0]))
|
| 100 |
|
|
|
|
| 137 |
|
| 138 |
generate_btn.click(
|
| 139 |
fn=execute_jupyter_agent,
|
| 140 |
+
inputs=[system_input, user_input, max_tokens, model, files, msg_state, sbx_state],
|
| 141 |
+
outputs=[html_output, msg_state],
|
| 142 |
)
|
| 143 |
|
| 144 |
+
clear_btn.click(fn=clear, inputs=[msg_state, sbx_state], outputs=[html_output, msg_state, sbx_state])
|
| 145 |
|
| 146 |
demo.load(
|
| 147 |
fn=None,
|