Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
from smolagents import CodeAgent,
|
| 2 |
import datetime
|
| 3 |
import pytz
|
| 4 |
import yaml
|
| 5 |
|
| 6 |
-
#
|
| 7 |
try:
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
except ImportError:
|
|
@@ -36,13 +36,15 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 36 |
return f"Error: {str(e)}"
|
| 37 |
|
| 38 |
|
| 39 |
-
# ------------------ MODEL ------------------ #
|
| 40 |
-
model =
|
| 41 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 42 |
-
max_tokens=1024, # safer for Spaces
|
| 43 |
temperature=0.5,
|
|
|
|
| 44 |
)
|
| 45 |
|
|
|
|
|
|
|
| 46 |
|
| 47 |
# ------------------ LOAD PROMPTS ------------------ #
|
| 48 |
try:
|
|
@@ -61,7 +63,7 @@ tools = [
|
|
| 61 |
get_current_time_in_timezone,
|
| 62 |
]
|
| 63 |
|
| 64 |
-
# Optional
|
| 65 |
try:
|
| 66 |
image_generation_tool = load_tool(
|
| 67 |
"agents-course/text-to-image",
|
|
@@ -76,7 +78,7 @@ except Exception:
|
|
| 76 |
agent = CodeAgent(
|
| 77 |
model=model,
|
| 78 |
tools=tools,
|
| 79 |
-
max_steps=4,
|
| 80 |
verbosity_level=1,
|
| 81 |
prompt_templates=prompt_templates,
|
| 82 |
)
|
|
@@ -85,5 +87,4 @@ agent = CodeAgent(
|
|
| 85 |
# ------------------ UI ------------------ #
|
| 86 |
app = GradioUI(agent)
|
| 87 |
|
| 88 |
-
# IMPORTANT for Spaces
|
| 89 |
app.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, HfApiModel, tool, load_tool
|
| 2 |
import datetime
|
| 3 |
import pytz
|
| 4 |
import yaml
|
| 5 |
|
| 6 |
+
# ------------------ SAFE IMPORT ------------------ #
|
| 7 |
try:
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
except ImportError:
|
|
|
|
| 36 |
return f"Error: {str(e)}"
|
| 37 |
|
| 38 |
|
| 39 |
+
# ------------------ MODEL (UPDATED) ------------------ #
|
| 40 |
+
model = HfApiModel(
|
| 41 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
|
|
|
| 42 |
temperature=0.5,
|
| 43 |
+
max_tokens=1024,
|
| 44 |
)
|
| 45 |
|
| 46 |
+
# ⚠️ Requires HF_TOKEN in Spaces secrets
|
| 47 |
+
|
| 48 |
|
| 49 |
# ------------------ LOAD PROMPTS ------------------ #
|
| 50 |
try:
|
|
|
|
| 63 |
get_current_time_in_timezone,
|
| 64 |
]
|
| 65 |
|
| 66 |
+
# Optional tool
|
| 67 |
try:
|
| 68 |
image_generation_tool = load_tool(
|
| 69 |
"agents-course/text-to-image",
|
|
|
|
| 78 |
agent = CodeAgent(
|
| 79 |
model=model,
|
| 80 |
tools=tools,
|
| 81 |
+
max_steps=4,
|
| 82 |
verbosity_level=1,
|
| 83 |
prompt_templates=prompt_templates,
|
| 84 |
)
|
|
|
|
| 87 |
# ------------------ UI ------------------ #
|
| 88 |
app = GradioUI(agent)
|
| 89 |
|
|
|
|
| 90 |
app.launch(server_name="0.0.0.0", server_port=7860)
|