You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Azure OpenAI service endpoint and deployment configured](/azure/ai-foundry/openai/how-to/create-resource)
27
27
-[Azure CLI installed](/cli/azure/install-azure-cli) and [authenticated (for Azure credential authentication)](/cli/azure/authenticate-azure-cli)
28
-
-[User has the `Cognitive Services OpenAI User` or `Cognitive Services OpenAI Contributor` roles, depending on need, for the Azure OpenAI resource.](/azure/ai-foundry/openai/how-to/role-based-access-control)
28
+
-[User has the `Cognitive Services OpenAI User` or `Cognitive Services OpenAI Contributor` roles for the Azure OpenAI resource.](/azure/ai-foundry/openai/how-to/role-based-access-control)
29
29
30
30
> [!NOTE]
31
31
> The Microsoft Agent Framework is supported with all actively supported versions of .net. For the purposes of this sample we are recommending the .NET 8.0 SDK or higher.
32
32
> [!IMPORTANT]
33
-
> For this tutorial we are using Azure OpenAI for the Chat Completion service, but you can use any inference service that is compatible with [Microsoft.Extensions.AI.IChatClient](/dotnet/api/microsoft.extensions.ai.ichatclient).
33
+
> For this tutorial we are using Azure OpenAI for the Chat Completion service, but you can use any inference service that provides a [Microsoft.Extensions.AI.IChatClient](/dotnet/api/microsoft.extensions.ai.ichatclient) implementation.
- First we create create a client for Azure OpenAI, by providing the Azure OpenAI endpoint and using the same login as was used when authenticating with the Azure CLI in the [Prerequisites](#prerequisites) step.
48
+
- First we create a client for Azure OpenAI, by providing the Azure OpenAI endpoint and using the same login as was used when authenticating with the Azure CLI in the [Prerequisites](#prerequisites) step.
49
49
- Then we get a chat client for communicating with the chat completion service, where we also specify the specific model deployment to use. Use one of the deployments that you created in the [Prerequisites](#prerequisites) step.
50
50
- Finally we create the agent, providing instructions and a name for the agent.
51
51
@@ -67,16 +67,24 @@ AIAgent agent = new AzureOpenAIClient(
67
67
## Running the agent
68
68
69
69
To run the agent, call the `RunAsync` method on the agent instance, providing the user input.
70
-
The agent will return a response object, and calling `.ToString()` or `.Text` on this response object, provides the text result from the agent.
70
+
The agent will return an `AgentRunResponse` object, and calling `.ToString()` or `.Text` on this response object, provides the text result from the agent.
71
71
72
72
```csharp
73
73
Console.WriteLine(awaitagent.RunAsync("Tell me a joke about a pirate."));
74
74
```
75
75
76
+
Sample output:
77
+
78
+
```text
79
+
Why did the pirate go to school?
80
+
81
+
Because he wanted to improve his "arrr-ticulation"! 🏴☠️
82
+
```
83
+
76
84
## Running the agent with streaming
77
85
78
86
To run the agent with streaming, call the `RunStreamingAsync` method on the agent instance, providing the user input.
79
-
The agent will stream a list of update objects, and calling `.ToString()` or `.Text` on each update object provides the part of the text result contained in that update.
87
+
The agent will return a stream `AgentRunResponseUpdate` objects, and calling `.ToString()` or `.Text` on each update object provides the part of the text result contained in that update.
80
88
81
89
```csharp
82
90
awaitforeach (varupdateinagent.RunStreamingAsync("Tell me a joke about a pirate."))
@@ -85,19 +93,72 @@ await foreach (var update in agent.RunStreamingAsync("Tell me a joke about a pir
85
93
}
86
94
```
87
95
88
-
## Running the agent with a ChatMessage
96
+
Sample output:
97
+
98
+
```text
99
+
Why
100
+
did
101
+
the
102
+
pirate
103
+
go
104
+
to
105
+
school
106
+
?
107
+
108
+
109
+
To
110
+
improve
111
+
his
112
+
"
113
+
ar
114
+
rrrr
115
+
rr
116
+
tic
117
+
ulation
118
+
!"
119
+
```
120
+
121
+
## Running the agent with ChatMessages
89
122
90
123
Instead of a simple string, you can also provide one or more `ChatMessage` objects to the `RunAsync` and `RunStreamingAsync` methods.
91
124
125
+
Here is an example with a single user message:
126
+
92
127
```csharp
93
128
ChatMessagemessage=new(ChatRole.User, [
94
129
newTextContent("Tell me a joke about this image?"),
I’m not a clown, but I can share an interesting fact! Did you know that pirates often revised the Jolly Roger flag? Depending on the pirate captain, it could feature different symbols like skulls, bones, or hourglasses, each representing their unique approach to piracy.
160
+
```
161
+
101
162
::: zone-end
102
163
::: zone pivot="programming-language-python"
103
164
@@ -113,7 +174,7 @@ Before you begin, ensure you have the following prerequisites:
113
174
-[Python 3.10 or later](https://www.python.org/downloads/)
114
175
-[Azure OpenAI service endpoint and deployment configured](/azure/ai-foundry/openai/how-to/create-resource)
115
176
-[Azure CLI installed](/cli/azure/install-azure-cli) and [authenticated (for Azure credential authentication)](/cli/azure/authenticate-azure-cli)
116
-
-[User has the `Cognitive Services OpenAI User` or `Cognitive Services OpenAI Contributor` roles, depending on need, for the Azure OpenAI resource.](/azure/ai-foundry/openai/how-to/role-based-access-control)
177
+
-[User has the `Cognitive Services OpenAI User` or `Cognitive Services OpenAI Contributor` roles for the Azure OpenAI resource.](/azure/ai-foundry/openai/how-to/role-based-access-control)
117
178
118
179
> [!IMPORTANT]
119
180
> For this tutorial we are using Azure OpenAI for the Chat Completion service, but you can use any inference service that is compatible with the Agent Framework's chat client protocol.
Copy file name to clipboardExpand all lines: agent-framework/tutorials/quick-start.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Before you begin, ensure you have the following:
23
23
-[.NET 8.0 SDK or later](https://dotnet.microsoft.com/download)
24
24
-[Azure OpenAI resource](/azure/ai-foundry/openai/how-to/create-resource) with a deployed model (e.g., `gpt-4o-mini`)
25
25
-[Azure CLI installed](/cli/azure/install-azure-cli) and [authenticated](/cli/azure/authenticate-azure-cli) (`az login`)
26
-
-[User has the `Cognitive Services OpenAI User` or `Cognitive Services OpenAI Contributor` roles, depending on need, for the Azure OpenAI resource.](/azure/ai-foundry/openai/how-to/role-based-access-control)
26
+
-[User has the `Cognitive Services OpenAI User` or `Cognitive Services OpenAI Contributor` roles for the Azure OpenAI resource.](/azure/ai-foundry/openai/how-to/role-based-access-control)
27
27
28
28
**Note**: The Microsoft Agent Framework is supported with all actively supported versions of .Net. For the purposes of this sample we are recommending the .NET 8.0 SDK or higher.
0 commit comments