Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,6 @@ from e2b_code_interpreter import Sandbox
|
|
| 6 |
from utils import run_interactive_notebook, create_base_notebook, update_notebook_display
|
| 7 |
|
| 8 |
|
| 9 |
-
message_history = []
|
| 10 |
-
|
| 11 |
E2B_API_KEY = os.environ['E2B_API_KEY']
|
| 12 |
HF_TOKEN = os.environ['HF_TOKEN']
|
| 13 |
DEFAULT_MAX_TOKENS = 512
|
|
@@ -31,19 +29,23 @@ NEVER ASSUME, ALWAYS VERIFY!"""
|
|
| 31 |
|
| 32 |
|
| 33 |
def execute_jupyter_agent(sytem_prompt, user_input, max_new_tokens):
|
|
|
|
| 34 |
client = InferenceClient(api_key=HF_TOKEN)
|
| 35 |
model = "meta-llama/Llama-3.1-8B-Instruct"
|
| 36 |
|
| 37 |
sbx = Sandbox(api_key=E2B_API_KEY)
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
{"role": "system", "content": sytem_prompt},
|
| 42 |
{"role": "user", "content": user_input}
|
| 43 |
]
|
| 44 |
else:
|
| 45 |
-
message_history.append({"role": "user", "content": user_input})
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
|
| 48 |
for notebook_html, message_history in run_interactive_notebook(client, model, messages, sbx, max_new_tokens=max_new_tokens):
|
| 49 |
yield notebook_html
|
|
|
|
| 6 |
from utils import run_interactive_notebook, create_base_notebook, update_notebook_display
|
| 7 |
|
| 8 |
|
|
|
|
|
|
|
| 9 |
E2B_API_KEY = os.environ['E2B_API_KEY']
|
| 10 |
HF_TOKEN = os.environ['HF_TOKEN']
|
| 11 |
DEFAULT_MAX_TOKENS = 512
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
def execute_jupyter_agent(sytem_prompt, user_input, max_new_tokens):
|
| 32 |
+
global message_history
|
| 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)
|
| 37 |
+
|
| 38 |
+
# Initialize message_history if it doesn't exist
|
| 39 |
+
if not hasattr(execute_jupyter_agent, 'message_history'):
|
| 40 |
+
execute_jupyter_agent.message_history = [
|
| 41 |
{"role": "system", "content": sytem_prompt},
|
| 42 |
{"role": "user", "content": user_input}
|
| 43 |
]
|
| 44 |
else:
|
| 45 |
+
execute_jupyter_agent.message_history.append({"role": "user", "content": user_input})
|
| 46 |
+
|
| 47 |
+
print("history", execute_jupyter_agent.message_history)
|
| 48 |
+
|
| 49 |
|
| 50 |
for notebook_html, message_history in run_interactive_notebook(client, model, messages, sbx, max_new_tokens=max_new_tokens):
|
| 51 |
yield notebook_html
|