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
This tutorial shows you how to create and run a simple agent, based on the Azure OpenAI Chat Completion service.
17
+
18
+
> [!IMPORTANT]
19
+
> The agent framework supports many different types of agents. This tutorial uses an agent based on a Chat Completion service, but all other agent types are run in the same way. See the [Agent Framework user guide](../user-guide/index.md) for more information on other agent types and how to construct them.
20
+
21
+
## Prerequisites
22
+
23
+
Before you begin, ensure you have the following prerequisites:
-[Azure OpenAI service endpoint and deployment configured](https://learn.microsoft.com/azure/ai-foundry/openai/how-to/create-resource)
27
+
-[Azure CLI installed](https://learn.microsoft.com/cli/azure/install-azure-cli) and [authenticated (for Azure credential authentication)](https://learn.microsoft.com/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.](https://learn.microsoft.com/azure/ai-foundry/openai/how-to/role-based-access-control)
29
+
30
+
> [!IMPORTANT]
31
+
> 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](https://learn.microsoft.com/dotnet/api/microsoft.extensions.ai.ichatclient).
32
+
33
+
## Installing Nuget packages
34
+
35
+
To use the AgentFramework with Azure OpenAI, you need to install the following NuGet packages:
36
+
37
+
```powershell
38
+
dotnet add package Azure.Identity
39
+
dotnet add package Azure.AI.OpenAI
40
+
dotnet add package Microsoft.Extensions.AI.OpenAI
41
+
dotnet add package Microsoft.Agents.OpenAI
42
+
```
43
+
44
+
## Creating the agent
45
+
46
+
- 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.
47
+
- 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.
48
+
- Finally we create the agent, providing instructions and a name for the agent.
49
+
50
+
```csharp
51
+
usingSystem;
52
+
usingAzure.AI.OpenAI;
53
+
usingAzure.Identity;
54
+
usingMicrosoft.Extensions.AI;
55
+
usingOpenAI;
56
+
57
+
AIAgentagent=newAzureOpenAIClient(
58
+
newUri("https://<myresource>.openai.azure.com"),
59
+
newAzureCliCredential())
60
+
.GetChatClient("gpt-4o-mini")
61
+
.CreateAIAgent(instructions: "You are good at telling jokes.", name: "Joker");
62
+
```
63
+
64
+
## Running the agent
65
+
66
+
To run the agent, call the `RunAsync` method on the agent instance, providing the user input.
67
+
The agent will return a response object, and calling `.ToString()` or `.Text` on this response object, provides the text result from the agent.
68
+
69
+
```csharp
70
+
Console.WriteLine(awaitagent.RunAsync("Tell me a joke about a pirate."));
71
+
```
72
+
73
+
## Running the agent with streaming
74
+
75
+
To run the agent with streaming, call the `RunStreamingAsync` method on the agent instance, providing the user input.
76
+
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.
77
+
78
+
```csharp
79
+
awaitforeach (varupdateinagent.RunStreamingAsync("Tell me a joke about a pirate."))
80
+
{
81
+
Console.WriteLine(update);
82
+
}
83
+
```
84
+
85
+
## Running the agent with a ChatMessage
86
+
87
+
Instead of a simple string, you can also provide one or more `ChatMessage` objects to the `RunAsync` and `RunStreamingAsync` methods.
88
+
89
+
```csharp
90
+
ChatMessagemessage=new(ChatRole.User, [
91
+
newTextContent("Tell me a joke about this image?"),
Copy file name to clipboardExpand all lines: semantic-kernel/concepts/vector-store-connectors/out-of-the-box-connectors/oracle-connector.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ The Oracle Database Vector Store Connector can be used to access and manage data
42
42
| Supported data property types | <ul><li>bool</li><li>byte</li><li>short</li><li>int</li><li>decimal</li><li>long</li><li>float</li><li>double</li><li>DateTime</li><li>DateTimeOffset</li><li>TimeSpan</li><li>char</li><li>char[]</li><li>byte[]</li><li>String</li><li>Guid</li><li>*and nullable type of the above types*</i></li></ul> |
| Supported distance functions | <ul><li>CosineDistance</li><ul><li>FLOAT32, FLOAT64, and INT8 vector default</li></ul><li>CosineSimilarity</li><li>DotProductSimilarity</li><li>NegativeDotProductSimilarity</li><li>EuclideanDistance</li><li>EuclideanSquaredDistance</li><li>HammingDistance</li><ul><li>BINARY vector default</li></ul><li>ManhattanDistance</li><li>JaccardSimilarity<br> To use Jaccard similarity, set the DistanceFunction string to "JACCARD" or "JACCARDSIMILARITY" (for example, DistanceFunction = "JACCARDSIMILARITY"). This value is case sensitive. Jaccard similarity requires BINARY numeric format vectors. </li></ul> |
46
46
| Supported filter clauses | <ul><li>==</li><li>!=</li><li><</li><li><=</li><li>></li><li>>=</li><li>List.Contains() <ul><li>Only when checking if the model property is in the list</li></ul></li></ul> |
47
47
| Supports zero, one, or multiple vectors in a record | Yes |
48
48
| IsIndexed supported? | Yes |
@@ -266,7 +266,7 @@ The Oracle Database Vector Store connector provides a default mapper when mappin
266
266
267
267
The Oracle Database Vector Store connector supports data model annotations and record definitions.Using annotations, the information can be provided to the data model for creating indexes and database column mapping. Using [record definitions](../schema-with-record-definition.md), the information can be defined and supplied separately from the data model.
268
268
269
-
The following table shows the default primary key data type mapping between Oracle database and C#:
269
+
The following table shows the default primary key data type mapping between Oracle Database and C#:
@@ -361,10 +361,10 @@ The Oracle Database Vector Store connector provides a default mapper when mappin
361
361
362
362
The Oracle Database Vector Store connector supports data model annotations and record definitions.Using annotations, the information can be provided to the data model for creating indexes and database column mapping. Using [record definitions](../schema-with-record-definition.md), the information can be defined and supplied separately from the data model.
363
363
364
-
The following table shows the default primary key data type mapping between Oracle database and Java, along with the corresponding methods to retrieve data from a `ResultSet`:
364
+
The following table shows the default primary key data type mapping between Oracle Database and Java, along with the corresponding methods to retrieve data from a `ResultSet`:
365
365
366
366
| Java Type | Database Type | ResultSet Getter Method |
@@ -375,7 +375,7 @@ The following table shows the default primary key data type mapping between Orac
375
375
The following table shows the default data property type mapping along with the corresponding methods to retrieve data from a `ResultSet`:
376
376
377
377
| Java Type | Database Type | ResultSet Getter Method |
378
-
| ------------- |:-------------:| -----:|
378
+
| ------------- |-------------| -----|
379
379
| boolean | BOOLEAN |`resultSet.getByte(name)`|
380
380
|byte/Byte |NUMBER(3)|`resultSet.getByte(name)`|
381
381
|byte[]|RAW(2000)|`resultSet.getBytes(name)`|
@@ -392,8 +392,8 @@ The following table shows the default data property type mapping along with the
392
392
393
393
Starting with Oracle Database 23ai, database vectors can be mapped to Java data types. Multiple vector columns are supported. The following table shows the default vector property type mapping:
0 commit comments