1010from agents import Agent , OpenAIConversationsSession , Runner
1111
1212
13- async def main ():
13+ def main ():
1414 # Create an agent
1515 agent = Agent (
1616 name = "Assistant" ,
@@ -26,7 +26,7 @@ async def main():
2626 # First turn
2727 print ("First turn:" )
2828 print ("User: What city is the Golden Gate Bridge in?" )
29- result = await Runner .run (
29+ result = Runner .run_sync (
3030 agent ,
3131 "What city is the Golden Gate Bridge in?" ,
3232 session = session ,
@@ -37,14 +37,14 @@ async def main():
3737 # Second turn - the agent will remember the previous conversation
3838 print ("Second turn:" )
3939 print ("User: What state is it in?" )
40- result = await Runner .run (agent , "What state is it in?" , session = session )
40+ result = Runner .run_sync (agent , "What state is it in?" , session = session )
4141 print (f"Assistant: { result .final_output } " )
4242 print ()
4343
4444 # Third turn - continuing the conversation
4545 print ("Third turn:" )
4646 print ("User: What's the population of that state?" )
47- result = await Runner .run (
47+ result = Runner .run_sync (
4848 agent ,
4949 "What's the population of that state?" ,
5050 session = session ,
@@ -72,7 +72,3 @@ async def main():
7272 all_items = await session .get_items ()
7373 # print(all_items)
7474 print (f"Total items in session: { len (all_items )} " )
75-
76-
77- if __name__ == "__main__" :
78- asyncio .run (main ())
0 commit comments