Skip to content

Commit 0d523da

Browse files
committed
Fixed code sample
1 parent ac56f4e commit 0d523da

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

learn-pr/wwl-data-ai/develop-ai-agent-with-semantic-kernel/includes/3-create-azure-ai-agent.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,24 @@ async with (@
4040
)
4141
```
4242

43-
Once your agent is defined, you can interact with your agent and invoke responses for inputs. To invoke responses, you create an agent thread and use the agent to add prompt and retrieve a response. For example:
43+
Once your agent is defined, you can create a thread to interact with your agent and invoke responses for inputs. For example:
4444

4545
```python
46-
thread: AzureAIAgentThread = AzureAIAgentThread()
46+
# Use the client agent service to create a thread
47+
thread = await client.agents.create_thread()
4748

4849
try:
49-
# Create a prompt
50-
prompt = "What are the largest semiconductor manufacturing companies?"
50+
# Create prompts
51+
prompt_messages = ["What are the largest semiconductor manufacturing companies?"]
5152

52-
# Instruct the agent to add a message to the thread
53-
await agent.add_chat_message(thread_id=thread.id, message=prompt)
53+
# Invoke a response from the agent
54+
response = await agent.get_response(messages=prompt_messages, thread_id=thread.id)
5455

55-
# Invoke the agent for response on the thread
56-
response = await agent.get_response(thread_id=thread.id)
56+
# View the response
57+
print(response)
5758
finally:
58-
await thread.delete() if thread else None
59+
# Clean up the thread
60+
await client.agents.delete_thread(thread.id)
5961
```
6062

6163
### AzureAIAgent key components

0 commit comments

Comments
 (0)