10
10
from agents import Agent , OpenAIConversationsSession , Runner
11
11
12
12
13
- async def main ():
13
+ def main ():
14
14
# Create an agent
15
15
agent = Agent (
16
16
name = "Assistant" ,
@@ -26,7 +26,7 @@ async def main():
26
26
# First turn
27
27
print ("First turn:" )
28
28
print ("User: What city is the Golden Gate Bridge in?" )
29
- result = await Runner .run (
29
+ result = Runner .run_sync (
30
30
agent ,
31
31
"What city is the Golden Gate Bridge in?" ,
32
32
session = session ,
@@ -37,14 +37,14 @@ async def main():
37
37
# Second turn - the agent will remember the previous conversation
38
38
print ("Second turn:" )
39
39
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 )
41
41
print (f"Assistant: { result .final_output } " )
42
42
print ()
43
43
44
44
# Third turn - continuing the conversation
45
45
print ("Third turn:" )
46
46
print ("User: What's the population of that state?" )
47
- result = await Runner .run (
47
+ result = Runner .run_sync (
48
48
agent ,
49
49
"What's the population of that state?" ,
50
50
session = session ,
@@ -72,7 +72,3 @@ async def main():
72
72
all_items = await session .get_items ()
73
73
# print(all_items)
74
74
print (f"Total items in session: { len (all_items )} " )
75
-
76
-
77
- if __name__ == "__main__" :
78
- asyncio .run (main ())
0 commit comments