@@ -98,24 +98,40 @@ async def run_weather_agent(user_input: str):
9898 weather_agent ,
9999 user_input ,
100100 metric_collection = "test_collection_1" ,
101- name = "test_name_1" ,
102- user_id = "test_user_id_1" ,
103- thread_id = "test_thread_id_1" ,
104- tags = ["test_tag_1" ],
105- metadata = {"test_metadata_1" : "test_metadata_1" },
101+ # name="test_name_1",
102+ # user_id="test_user_id_1",
103+ # thread_id="test_thread_id_1",
104+ # tags=["test_tag_1"],
105+ # metadata={"test_metadata_1": "test_metadata_1"},
106106 )
107107 return result .final_output
108108
109-
110- # Usage example
111- async def main ():
109+ from agents import trace
110+ from multi_agents import triage_agent
111+ # with trace (group_id and metadata)
112+ async def main1 ():
113+ with trace (workflow_name = "test_workflow_1" , group_id = "test_group_id_1" , metadata = {"test_metadata_1" : "test_metadata_1" }):
114+ user_query = "What's the weather like in London today?"
115+ response_2 = await Runner .run (weather_agent , user_query , metric_collection = "test_collection_1" )
116+ response_1 = await Runner .run (triage_agent , "Hola, ¿cómo estás?" , metric_collection = "test_collection_1" , thread_id = "test" )
117+
118+ # without trace (group_id and metadata not present)
119+ async def main2 ():
112120 user_query = "What's the weather like in London today?"
113- response = await run_weather_agent ( user_query )
114- print ( f"Agent Response: { response } " )
121+ response_2 = await Runner . run ( weather_agent , user_query , metric_collection = "test_collection_1" )
122+ response_1 = await Runner . run ( triage_agent , "Hola, ¿cómo estás?" , metric_collection = "test_collection_1" , thread_id = "test " )
115123
124+ async def main3 ():
125+ user_query = "What's the weather like in London today?"
126+ with trace (workflow_name = "test_workflow_1" , group_id = "test_group_id_1" , metadata = {"test_metadata_1" : "test_metadata_1" }):
127+ response_2 = await Runner .run (weather_agent , user_query , metric_collection = "test_collection_1" )
128+ with trace (workflow_name = "test_workflow_2" , group_id = "test_group_id_2" , metadata = {"test_metadata_2" : "test_metadata_2" }):
129+ response_1 = await Runner .run (triage_agent , "Hola, ¿cómo estás?" , metric_collection = "test_collection_1" , thread_id = "test" )
116130
117131def execute_agent ():
118- return asyncio .run (main ())
132+ asyncio .run (main1 ())
133+ asyncio .run (main2 ())
134+ asyncio .run (main3 ())
119135
120136
121- execute_agent ()
137+ # execute_agent()
0 commit comments