Spaces:
Running
Running
Nathan Brake
commited on
Update to match new any_agent tracing api (#44)
Browse files- examples/langchain_single_agent_user_confirmation.yaml +1 -1
- examples/openai_single_agent_user_confirmation.yaml +17 -2
- examples/smolagents_single_agent_user_confirmation.yaml +1 -1
- src/surf_spot_finder/cli.py +3 -1
- src/surf_spot_finder/evaluation/evaluate.py +3 -1
- src/surf_spot_finder/evaluation/telemetry/openai_telemetry.py +3 -3
examples/langchain_single_agent_user_confirmation.yaml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
|
2 |
location: Pontevedra
|
3 |
-
date: 2025-
|
4 |
max_driving_hours: 2
|
5 |
input_prompt_template: |
|
6 |
According to the forecast, what will be the best spot to surf around {LOCATION},
|
|
|
1 |
|
2 |
location: Pontevedra
|
3 |
+
date: 2025-04-05 12:00
|
4 |
max_driving_hours: 2
|
5 |
input_prompt_template: |
|
6 |
According to the forecast, what will be the best spot to surf around {LOCATION},
|
examples/openai_single_agent_user_confirmation.yaml
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
|
2 |
location: Pontevedra
|
3 |
-
date: 2025-
|
4 |
max_driving_hours: 2
|
5 |
input_prompt_template: |
|
6 |
According to the forecast, what will be the best spot to surf around {LOCATION},
|
7 |
in a {MAX_DRIVING_HOURS} hour driving radius, at {DATE}?
|
8 |
Find a few options and then discuss it with David de la Iglesia Castro. You should recommend him some choices,
|
9 |
and then confirm the final selection with him.
|
10 |
-
|
|
|
11 |
framework: openai
|
12 |
|
13 |
main_agent:
|
@@ -20,3 +21,17 @@ main_agent:
|
|
20 |
- "surf_spot_finder.tools.get_wave_forecast"
|
21 |
- "surf_spot_finder.tools.get_wind_forecast"
|
22 |
- "any_agent.tools.send_console_message"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
location: Pontevedra
|
3 |
+
date: 2025-04-05 12:00
|
4 |
max_driving_hours: 2
|
5 |
input_prompt_template: |
|
6 |
According to the forecast, what will be the best spot to surf around {LOCATION},
|
7 |
in a {MAX_DRIVING_HOURS} hour driving radius, at {DATE}?
|
8 |
Find a few options and then discuss it with David de la Iglesia Castro. You should recommend him some choices,
|
9 |
and then confirm the final selection with him.
|
10 |
+
Once he gives the final selection, save a detailed description of the weather at the chosen location into a file
|
11 |
+
named "final_answer.txt". Also save a file called "history.txt" which has a list of your thought process in the choice.
|
12 |
framework: openai
|
13 |
|
14 |
main_agent:
|
|
|
21 |
- "surf_spot_finder.tools.get_wave_forecast"
|
22 |
- "surf_spot_finder.tools.get_wind_forecast"
|
23 |
- "any_agent.tools.send_console_message"
|
24 |
+
- command: "docker"
|
25 |
+
args:
|
26 |
+
- "run"
|
27 |
+
- "-i"
|
28 |
+
- "--rm"
|
29 |
+
- "--mount"
|
30 |
+
- "type=bind,src=/tmp/surf-spot-finder,dst=/projects"
|
31 |
+
- "mcp/filesystem"
|
32 |
+
- "/projects"
|
33 |
+
tools:
|
34 |
+
- "read_file"
|
35 |
+
- "write_file"
|
36 |
+
- "directory_tree"
|
37 |
+
- "list_allowed_directories"
|
examples/smolagents_single_agent_user_confirmation.yaml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
location: Pontevedra
|
2 |
-
date: 2025-
|
3 |
max_driving_hours: 2
|
4 |
input_prompt_template: |
|
5 |
According to the forecast, what will be the best spot to surf around {LOCATION},
|
|
|
1 |
location: Pontevedra
|
2 |
+
date: 2025-04-05 12:00
|
3 |
max_driving_hours: 2
|
4 |
input_prompt_template: |
|
5 |
According to the forecast, what will be the best spot to surf around {LOCATION},
|
src/surf_spot_finder/cli.py
CHANGED
@@ -26,7 +26,9 @@ def find_surf_spot(
|
|
26 |
config = Config.model_validate(yaml.safe_load(Path(config_file).read_text()))
|
27 |
|
28 |
logger.info("Setting up tracing")
|
29 |
-
tracer_provider, tracing_path = get_tracer_provider(
|
|
|
|
|
30 |
setup_tracing(tracer_provider, config.framework)
|
31 |
|
32 |
logger.info(f"Loading {config.framework} agent")
|
|
|
26 |
config = Config.model_validate(yaml.safe_load(Path(config_file).read_text()))
|
27 |
|
28 |
logger.info("Setting up tracing")
|
29 |
+
tracer_provider, tracing_path = get_tracer_provider(
|
30 |
+
project_name="surf-spot-finder", agent_framework=config.framework
|
31 |
+
)
|
32 |
setup_tracing(tracer_provider, config.framework)
|
33 |
|
34 |
logger.info(f"Loading {config.framework} agent")
|
src/surf_spot_finder/evaluation/evaluate.py
CHANGED
@@ -33,7 +33,9 @@ def run(test_case: TestCase, agent_config_path: str) -> str:
|
|
33 |
config.date = input_data.date
|
34 |
config.max_driving_hours = input_data.max_driving_hours
|
35 |
logger.info("Setting up tracing")
|
36 |
-
tracer_provider, tracing_path = get_tracer_provider(
|
|
|
|
|
37 |
setup_tracing(tracer_provider, config.framework)
|
38 |
|
39 |
logger.info(f"Loading {config.framework} agent")
|
|
|
33 |
config.date = input_data.date
|
34 |
config.max_driving_hours = input_data.max_driving_hours
|
35 |
logger.info("Setting up tracing")
|
36 |
+
tracer_provider, tracing_path = get_tracer_provider(
|
37 |
+
project_name="surf-spot-finder", agent_framework=config.framework
|
38 |
+
)
|
39 |
setup_tracing(tracer_provider, config.framework)
|
40 |
|
41 |
logger.info(f"Loading {config.framework} agent")
|
src/surf_spot_finder/evaluation/telemetry/openai_telemetry.py
CHANGED
@@ -2,7 +2,7 @@ from typing import Any, Dict, List
|
|
2 |
import json
|
3 |
|
4 |
from any_agent import AgentFramework
|
5 |
-
|
6 |
from surf_spot_finder.evaluation.telemetry import TelemetryProcessor
|
7 |
|
8 |
|
@@ -24,8 +24,8 @@ class OpenAITelemetryProcessor(TelemetryProcessor):
|
|
24 |
)
|
25 |
if output_key in span["attributes"]:
|
26 |
return span["attributes"][output_key]
|
27 |
-
|
28 |
-
|
29 |
|
30 |
def _extract_telemetry_data(self, telemetry: List[Dict[str, Any]]) -> list:
|
31 |
"""Extract LLM calls and tool calls from OpenAI telemetry."""
|
|
|
2 |
import json
|
3 |
|
4 |
from any_agent import AgentFramework
|
5 |
+
from loguru import logger
|
6 |
from surf_spot_finder.evaluation.telemetry import TelemetryProcessor
|
7 |
|
8 |
|
|
|
24 |
)
|
25 |
if output_key in span["attributes"]:
|
26 |
return span["attributes"][output_key]
|
27 |
+
logger.warning("No agent final answer found in trace")
|
28 |
+
return "NO FINAL ANSWER FOUND"
|
29 |
|
30 |
def _extract_telemetry_data(self, telemetry: List[Dict[str, Any]]) -> list:
|
31 |
"""Extract LLM calls and tool calls from OpenAI telemetry."""
|