Skip to content

Commit 0eed6d3

Browse files
Merge pull request #45672 from dotnet/main
Merge main into live
2 parents faa2fde + 412a4e5 commit 0eed6d3

File tree

19 files changed

+404
-116
lines changed

19 files changed

+404
-116
lines changed

docs/ai/quickstarts/build-chat-app.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ Complete the following steps to create a .NET console app to connect to an AI mo
5454
:::zone target="docs" pivot="azure-openai"
5555
5656
```bash
57-
dotnet package add Azure.Identity
58-
dotnet package add Azure.AI.OpenAI
59-
dotnet package add Microsoft.Extensions.AI.OpenAI
60-
dotnet package add Microsoft.Extensions.Configuration
61-
dotnet package add Microsoft.Extensions.Configuration.UserSecrets
57+
dotnet add package Azure.Identity
58+
dotnet add package Azure.AI.OpenAI
59+
dotnet add package Microsoft.Extensions.AI.OpenAI
60+
dotnet add package Microsoft.Extensions.Configuration
61+
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
6262
```
6363
6464
:::zone-end
6565
6666
:::zone target="docs" pivot="openai"
6767
6868
```bash
69-
dotnet package add OpenAI
70-
dotnet package add Microsoft.Extensions.AI.OpenAI
71-
dotnet package add Microsoft.Extensions.Configuration
72-
dotnet package add Microsoft.Extensions.Configuration.UserSecrets
69+
dotnet add package OpenAI
70+
dotnet add package Microsoft.Extensions.AI.OpenAI
71+
dotnet add package Microsoft.Extensions.Configuration
72+
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
7373
```
7474
7575
:::zone-end

docs/ai/quickstarts/build-vector-search-app.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ Complete the following steps to create a .NET console app that can:
154154
155155
1. In the **Program.cs** file, add the following code to create a data set that describes a collection of cloud services:
156156
157-
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="8-46":::
157+
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="DataSet":::
158158
159159
1. Create and configure an `IEmbeddingGenerator` implementation to send requests to an embedding AI model:
160160
161161
:::zone target="docs" pivot="azure-openai"
162162
163-
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="48-58":::
163+
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="EmbeddingGen":::
164164
165165
> [!NOTE]
166166
> <xref:Azure.Identity.DefaultAzureCredential> searches for authentication credentials from your local tooling. If you aren't using the `azd` template to provision the Azure OpenAI resource, you'll need to assign the `Azure AI Developer` role to the account you used to sign in to Visual Studio or the Azure CLI. For more information, see [Authenticate to Azure AI services with .NET](../azure-ai-services-authentication.md).
@@ -175,13 +175,13 @@ Complete the following steps to create a .NET console app that can:
175175
176176
1. Create and populate a vector store with the cloud service data. Use the `IEmbeddingGenerator` implementation to create and assign an embedding vector for each record in the cloud service data:
177177
178-
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="61-70":::
178+
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="VectorStore":::
179179
180180
The embeddings are numerical representations of the semantic meaning for each data record, which makes them compatible with vector search features.
181181
182182
1. Create an embedding for a search query and use it to perform a vector search on the vector store:
183183
184-
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="72-88":::
184+
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="Search":::
185185
186186
1. Use the `dotnet run` command to run the app:
187187

docs/ai/quickstarts/snippets/chat-with-data/azure-openai/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.SemanticKernel.Connectors.InMemory;
77
using VectorDataAI;
88

9+
// <SnippetDataSet>
910
var cloudServices = new List<CloudService>()
1011
{
1112
new CloudService
@@ -45,7 +46,9 @@
4546
Description="Information retrieval at scale for traditional and conversational search applications, with security and options for AI enrichment and vectorization."
4647
}
4748
};
49+
// </SnippetDataSet>
4850

51+
// <SnippetEmbeddingGen>
4952
// Load the configuration values
5053
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
5154
string endpoint = config["AZURE_OPENAI_ENDPOINT"];
@@ -57,7 +60,9 @@
5760
new Uri(endpoint),
5861
new DefaultAzureCredential())
5962
.AsEmbeddingGenerator(modelId: model);
63+
// </SnippetEmbeddingGen>
6064

65+
// <SnippetVectorStore>
6166
// Create and populate the vector store
6267
var vectorStore = new InMemoryVectorStore();
6368
Microsoft.Extensions.VectorData.IVectorStoreRecordCollection<int, CloudService> cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
@@ -68,7 +73,9 @@
6873
service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description);
6974
await cloudServicesStore.UpsertAsync(service);
7075
}
76+
// </SnippetVectorStore>
7177

78+
// <SnippetSearch>
7279
// Convert a search query to a vector and search the vector store
7380
string query = "Which Azure service should I use to store my Word documents?";
7481
ReadOnlyMemory<float> queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query);
@@ -86,3 +93,4 @@
8693
Console.WriteLine($"Vector match score: {result.Score}");
8794
Console.WriteLine();
8895
}
96+
// </SnippetSearch>

0 commit comments

Comments
 (0)