Skip to content

Commit dd2e63b

Browse files
committed
Add code
1 parent c6f4c60 commit dd2e63b

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

articles/ai-services/agents/overview.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,36 @@ Azure AI Agent Service is a fully managed service designed to empower developers
1919

2020
Within Azure AI Foundry, an AI Agent acts as a "smart" microservice that can be used to answer questions (RAG), perform actions, or completely automate workflows. It achieves this by combining the power of generative AI models with tools that allow it to access and interact with real-world data sources.
2121

22-
// Add a diagram here
23-
2422
Because Azure AI Agent Service uses the same wire protocol as [Azure OpenAI Assistants](/azure/ai-services/openai/how-to/assistant), you can use either [OpenAI SDKs](./quickstart.md?pivots=programming-language-python-openai) or [Azure AI Foundry SDKs](./quickstart.md?programming-language-python-azure) to create and run an agent in just a few lines of code. For example, to create an AI Agent with Azure AI Foundry SDK, you can simply define which model the AI uses, the instructions for how it should complete tasks, and the tools it can use to access and interact with other services.
2523

26-
// Add code here
24+
```python
25+
agent = project_client.agents.create_agent(
26+
model="gpt-4o-mini",
27+
name="my-agent",
28+
instructions="You are helpful agent",
29+
tools=code_interpreter.definitions,
30+
tool_resources=code_interpreter.resources,
31+
)
32+
```
2733

2834
After defining an agent, you can start asking it to perform work by invoking a run on top of an activity thread, which is simply a conversation between multiple agents and users.
2935

30-
// Add code here
36+
```python
37+
# Create a thread with messages
38+
thread = project_client.agents.create_thread()
39+
message = project_client.agents.create_message(
40+
thread_id=thread.id,
41+
role="user",
42+
content="Could you please create a bar chart for the operating profit using the following data and provide the file to me? Company A: $1.2 million, Company B: $2.5 million, Company C: $3.0 million, Company D: $1.8 million",
43+
)
44+
45+
# Ask the agent to perform work on the thread
46+
run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)
47+
48+
# Fetch and log all messages to see the agent's response
49+
messages = project_client.agents.list_messages(thread_id=thread.id)
50+
print(f"Messages: {messages}")
51+
```
3152

3253
Whenever the run operation is invoked, Azure AI Agent Service will complete the entire tool calling lifecycle for you by 1) running the model with the provided instructions, 2) invoking the tools as the agent calls them, and 3) returning the results back to you.
3354

0 commit comments

Comments
 (0)