Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +23 -7
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,14 +1,12 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import os
|
| 3 |
import gradio as gr
|
| 4 |
import requests
|
| 5 |
-
import inspect
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
from smolagents import CodeAgent
|
| 9 |
-
from smolagents
|
| 10 |
-
from smolagents.models import HfApiModel
|
| 11 |
-
from
|
| 12 |
|
| 13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 14 |
|
|
@@ -16,8 +14,26 @@ class BasicAgent:
|
|
| 16 |
def __init__(self):
|
| 17 |
model = HfApiModel(model="mistralai/Mistral-7B-Instruct-v0.2")
|
| 18 |
tools = [DuckDuckGoSearchTool()]
|
| 19 |
-
sandbox = E2BSandbox(
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def __call__(self, question: str) -> str:
|
| 23 |
return self.agent.run(question).strip()
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
|
|
|
| 4 |
import pandas as pd
|
| 5 |
|
| 6 |
from smolagents import CodeAgent
|
| 7 |
+
from smolagents import DuckDuckGoSearchTool
|
| 8 |
+
from smolagents.models import ApiModel as HfApiModel
|
| 9 |
+
from e2b_code_interpreter import Sandbox as E2BSandbox
|
| 10 |
|
| 11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 12 |
|
|
|
|
| 14 |
def __init__(self):
|
| 15 |
model = HfApiModel(model="mistralai/Mistral-7B-Instruct-v0.2")
|
| 16 |
tools = [DuckDuckGoSearchTool()]
|
| 17 |
+
sandbox = E2BSandbox(
|
| 18 |
+
template=None,
|
| 19 |
+
timeout=60,
|
| 20 |
+
metadata=None,
|
| 21 |
+
envs=None,
|
| 22 |
+
secure=True,
|
| 23 |
+
api_key=None,
|
| 24 |
+
domain=None,
|
| 25 |
+
debug=False,
|
| 26 |
+
sandbox_id=None,
|
| 27 |
+
request_timeout=30.0,
|
| 28 |
+
proxy=None
|
| 29 |
+
)
|
| 30 |
+
self.agent = CodeAgent(
|
| 31 |
+
tools=tools,
|
| 32 |
+
model=model,
|
| 33 |
+
executor_type="e2b",
|
| 34 |
+
executor_kwargs={"sandbox": sandbox},
|
| 35 |
+
additional_authorized_imports=["math", "datetime"]
|
| 36 |
+
)
|
| 37 |
|
| 38 |
def __call__(self, question: str) -> str:
|
| 39 |
return self.agent.run(question).strip()
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
gradio==5.25.2
|
| 2 |
requests
|
| 3 |
pandas
|
| 4 |
-
|
|
|
|
|
|
| 1 |
gradio==5.25.2
|
| 2 |
requests
|
| 3 |
pandas
|
| 4 |
+
smolagents[e2b]
|
| 5 |
+
https://github.com/huggingface/agents/archive/refs/heads/main.zip
|