@@ -79,32 +79,32 @@ with project_client:
79
79
)
80
80
print (f " Created agent, ID: { agent.id} " )
81
81
82
- # Create a thread for communication
83
- thread = project_client.agents.threads.create()
84
- print (f " Created thread, ID: { thread.id} " )
85
-
86
- # Add a message to the thread
87
- message = project_client.agents.messages.create(
88
- thread_id = thread.id,
89
- role = " user" , # Role of the message sender
90
- content = " What is the weather in Seattle today?" , # Message content
91
- )
92
- print (f " Created message, ID: { message[' id' ]} " )
93
-
94
- # Create and process an agent run
95
- run = project_client.agents.runs.create_and_process(thread_id = thread.id, agent_id = agent.id)
96
- print (f " Run finished with status: { run.status} " )
97
-
98
- # Check if the run failed
99
- if run.status == " failed" :
100
- print (f " Run failed: { run.last_error} " )
101
-
102
- # Fetch and log all messages
103
- messages = project_client.agents.messages.list(thread_id = thread.id)
104
- for message in messages.data :
105
- print (f " Role: { message.role} , Content: { message.content} " )
106
-
107
- # Delete the agent when done
108
- project_client.agents.delete_agent(agent.id)
109
- print (" Deleted agent" )
82
+ # Create a thread for communication
83
+ thread = project_client.agents.threads.create()
84
+ print (f " Created thread, ID: { thread.id} " )
85
+
86
+ # Add a message to the thread
87
+ message = project_client.agents.messages.create(
88
+ thread_id = thread.id,
89
+ role = " user" , # Role of the message sender
90
+ content = " What is the weather in Seattle today?" , # Message content
91
+ )
92
+ print (f " Created message, ID: { message[' id' ]} " )
93
+
94
+ # Create and process an agent run
95
+ run = project_client.agents.runs.create_and_process(thread_id = thread.id, agent_id = agent.id)
96
+ print (f " Run finished with status: { run.status} " )
97
+
98
+ # Check if the run failed
99
+ if run.status == " failed" :
100
+ print (f " Run failed: { run.last_error} " )
101
+
102
+ # Fetch and log all messages
103
+ messages = project_client.agents.messages.list(thread_id = thread.id)
104
+ for message in messages:
105
+ print (f " Role: { message.role} , Content: { message.content} " )
106
+
107
+ # Delete the agent when done
108
+ project_client.agents.delete_agent(agent.id)
109
+ print (" Deleted agent" )
110
110
```
0 commit comments