Romain Fayoux
commited on
Commit
·
81e3587
1
Parent(s):
24559eb
added telemetry
Browse files- .python-version +1 -0
- app.py +9 -1
- llm_only_agent.py +2 -2
- mise.toml +5 -0
- requirements.txt +1 -0
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.12
|
app.py
CHANGED
|
@@ -3,9 +3,12 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
|
|
|
| 6 |
from llm_only_agent import LLMOnlyAgent
|
| 7 |
import profile
|
| 8 |
|
|
|
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
| 11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -75,7 +78,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None, limit: int | None):
|
|
| 75 |
results_log = []
|
| 76 |
answers_payload = []
|
| 77 |
# Limit for test purposes
|
| 78 |
-
limit =
|
| 79 |
if limit is not None:
|
| 80 |
questions_data = questions_data[:limit]
|
| 81 |
print(f"Running agent on {len(questions_data)} questions...")
|
|
@@ -179,6 +182,11 @@ with gr.Blocks() as demo:
|
|
| 179 |
|
| 180 |
if __name__ == "__main__":
|
| 181 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
| 183 |
space_host_startup = os.getenv("SPACE_HOST")
|
| 184 |
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from phoenix.otel import register
|
| 7 |
+
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
| 8 |
from llm_only_agent import LLMOnlyAgent
|
| 9 |
import profile
|
| 10 |
|
| 11 |
+
|
| 12 |
# (Keep Constants as is)
|
| 13 |
# --- Constants ---
|
| 14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 78 |
results_log = []
|
| 79 |
answers_payload = []
|
| 80 |
# Limit for test purposes
|
| 81 |
+
limit = 2
|
| 82 |
if limit is not None:
|
| 83 |
questions_data = questions_data[:limit]
|
| 84 |
print(f"Running agent on {len(questions_data)} questions...")
|
|
|
|
| 182 |
|
| 183 |
if __name__ == "__main__":
|
| 184 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
| 185 |
+
|
| 186 |
+
# Telemetry
|
| 187 |
+
register()
|
| 188 |
+
SmolagentsInstrumentor().instrument()
|
| 189 |
+
|
| 190 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
| 191 |
space_host_startup = os.getenv("SPACE_HOST")
|
| 192 |
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
llm_only_agent.py
CHANGED
|
@@ -29,8 +29,8 @@ class LLMOnlyAgent:
|
|
| 29 |
instructions=self.instructions,
|
| 30 |
tools=[FinalAnswerTool(), WikipediaSearchTool(), WebSearchTool(), VisitWebpageTool()],
|
| 31 |
additional_authorized_imports=[ "markdownify" , "requests" ],
|
| 32 |
-
max_steps=
|
| 33 |
-
|
| 34 |
)
|
| 35 |
|
| 36 |
print("BasicAgent initialized.")
|
|
|
|
| 29 |
instructions=self.instructions,
|
| 30 |
tools=[FinalAnswerTool(), WikipediaSearchTool(), WebSearchTool(), VisitWebpageTool()],
|
| 31 |
additional_authorized_imports=[ "markdownify" , "requests" ],
|
| 32 |
+
max_steps=5,
|
| 33 |
+
final_answer_checks=self.final_answer_checks()
|
| 34 |
)
|
| 35 |
|
| 36 |
print("BasicAgent initialized.")
|
mise.toml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[tools]
|
| 2 |
+
python = "3.11"
|
| 3 |
+
|
| 4 |
+
[settings]
|
| 5 |
+
python.uv_venv_auto = true
|
requirements.txt
CHANGED
|
@@ -6,3 +6,4 @@ huggingface_hub[cli]
|
|
| 6 |
wikipedia-api
|
| 7 |
markdownify
|
| 8 |
requests
|
|
|
|
|
|
| 6 |
wikipedia-api
|
| 7 |
markdownify
|
| 8 |
requests
|
| 9 |
+
smolagents[telemetry,toolkit]
|