Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,18 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
-
# Minimal GAIA agent app.py (compatible toutes versions smolagents)
|
| 3 |
|
| 4 |
import os
|
| 5 |
import re
|
| 6 |
-
import json
|
| 7 |
import ast
|
| 8 |
import operator
|
| 9 |
import datetime
|
| 10 |
import pytz
|
| 11 |
-
import
|
| 12 |
import requests
|
|
|
|
| 13 |
import pandas as pd
|
| 14 |
import gradio as gr
|
| 15 |
|
| 16 |
-
# -------------------------
|
| 17 |
-
# smolagents imports
|
| 18 |
-
# -------------------------
|
| 19 |
from smolagents import CodeAgent, tool
|
| 20 |
-
from tools.final_answer import FinalAnswerTool
|
| 21 |
|
| 22 |
# -------------------------
|
| 23 |
# Minimal tools
|
|
@@ -61,10 +56,9 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 61 |
except Exception as e:
|
| 62 |
return json.dumps({"error": f"Timezone error: {e}"})
|
| 63 |
|
| 64 |
-
#
|
| 65 |
-
final_answer = FinalAnswerTool()
|
| 66 |
-
|
| 67 |
# Load prompts.yaml if exists
|
|
|
|
| 68 |
prompt_templates = None
|
| 69 |
try:
|
| 70 |
with open("prompts.yaml", "r") as fh:
|
|
@@ -78,8 +72,8 @@ except Exception:
|
|
| 78 |
MODEL_ID = 'Qwen/Qwen2.5-Coder-32B-Instruct'
|
| 79 |
|
| 80 |
code_agent = CodeAgent(
|
| 81 |
-
model=MODEL_ID, # directly pass string
|
| 82 |
-
tools=[
|
| 83 |
max_steps=6,
|
| 84 |
verbosity_level=0,
|
| 85 |
prompt_templates=prompt_templates
|
|
@@ -132,7 +126,7 @@ class GaiaAgentMinimal:
|
|
| 132 |
gaia_agent = GaiaAgentMinimal(code_agent)
|
| 133 |
|
| 134 |
# -------------------------
|
| 135 |
-
# GAIA runner
|
| 136 |
# -------------------------
|
| 137 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 138 |
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
|
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
import re
|
|
|
|
| 5 |
import ast
|
| 6 |
import operator
|
| 7 |
import datetime
|
| 8 |
import pytz
|
| 9 |
+
import json
|
| 10 |
import requests
|
| 11 |
+
import yaml
|
| 12 |
import pandas as pd
|
| 13 |
import gradio as gr
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
from smolagents import CodeAgent, tool
|
|
|
|
| 16 |
|
| 17 |
# -------------------------
|
| 18 |
# Minimal tools
|
|
|
|
| 56 |
except Exception as e:
|
| 57 |
return json.dumps({"error": f"Timezone error: {e}"})
|
| 58 |
|
| 59 |
+
# -------------------------
|
|
|
|
|
|
|
| 60 |
# Load prompts.yaml if exists
|
| 61 |
+
# -------------------------
|
| 62 |
prompt_templates = None
|
| 63 |
try:
|
| 64 |
with open("prompts.yaml", "r") as fh:
|
|
|
|
| 72 |
MODEL_ID = 'Qwen/Qwen2.5-Coder-32B-Instruct'
|
| 73 |
|
| 74 |
code_agent = CodeAgent(
|
| 75 |
+
model=MODEL_ID, # directly pass string
|
| 76 |
+
tools=[calculator, get_current_time_in_timezone],
|
| 77 |
max_steps=6,
|
| 78 |
verbosity_level=0,
|
| 79 |
prompt_templates=prompt_templates
|
|
|
|
| 126 |
gaia_agent = GaiaAgentMinimal(code_agent)
|
| 127 |
|
| 128 |
# -------------------------
|
| 129 |
+
# GAIA runner
|
| 130 |
# -------------------------
|
| 131 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 132 |
|