# /// script # requires-python = ">=3.10" # dependencies = [ # "arize-phoenix-client>=3.7,<4", # "arize-phoenix-otel>=0.17,<1", # "openinference-instrumentation-openai>=0.1.77", # "openai>=2", # ] # /// """Run hello_agent.py over a small dataset as a Phoenix experiment. Creates (or reuses) the "weather-questions" dataset, runs the agent on each example, and checks each answer names the expected city. Change the agent's prompt or model (MODEL=gpt-5.5 uv run experiment_agent.py) and run it again to compare experiments side by side under Datasets in the UI. """ import os from phoenix.client import Client from phoenix.client.experiments import run_experiment from hello_agent import MODEL, agent phoenix = Client() NAME = "weather-questions" try: dataset = phoenix.datasets.get_dataset(dataset=NAME) except Exception: dataset = phoenix.datasets.create_dataset( name=NAME, inputs=[ {"question": "Is it warmer in Lisbon or Oslo today?"}, {"question": "Which is colder today, Tokyo or Nairobi?"}, {"question": "Where should I go for the warmest day: Oslo, Tokyo or Nairobi?"}, ], outputs=[{"city": "Lisbon"}, {"city": "Tokyo"}, {"city": "Nairobi"}], ) def names_expected_city(output, expected) -> bool: return expected["city"].lower() in (output or "").lower() run_experiment( dataset=dataset, task=lambda input: agent(input["question"]), evaluators=[names_expected_city], experiment_name=f"agent on {MODEL}", )