Skip to content

Merge main into live #45672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/ai/quickstarts/build-chat-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ Complete the following steps to create a .NET console app to connect to an AI mo
:::zone target="docs" pivot="azure-openai"

```bash
dotnet package add Azure.Identity
dotnet package add Azure.AI.OpenAI
dotnet package add Microsoft.Extensions.AI.OpenAI
dotnet package add Microsoft.Extensions.Configuration
dotnet package add Microsoft.Extensions.Configuration.UserSecrets
dotnet add package Azure.Identity
dotnet add package Azure.AI.OpenAI
dotnet add package Microsoft.Extensions.AI.OpenAI
dotnet add package Microsoft.Extensions.Configuration
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
```

:::zone-end

:::zone target="docs" pivot="openai"

```bash
dotnet package add OpenAI
dotnet package add Microsoft.Extensions.AI.OpenAI
dotnet package add Microsoft.Extensions.Configuration
dotnet package add Microsoft.Extensions.Configuration.UserSecrets
dotnet add package OpenAI
dotnet add package Microsoft.Extensions.AI.OpenAI
dotnet add package Microsoft.Extensions.Configuration
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
```

:::zone-end
Expand Down
8 changes: 4 additions & 4 deletions docs/ai/quickstarts/build-vector-search-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ Complete the following steps to create a .NET console app that can:

1. In the **Program.cs** file, add the following code to create a data set that describes a collection of cloud services:

:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="8-46":::
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="DataSet":::

1. Create and configure an `IEmbeddingGenerator` implementation to send requests to an embedding AI model:

:::zone target="docs" pivot="azure-openai"

:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="48-58":::
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="EmbeddingGen":::

> [!NOTE]
> <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).
Expand All @@ -175,13 +175,13 @@ Complete the following steps to create a .NET console app that can:

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:

:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="61-70":::
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="VectorStore":::

The embeddings are numerical representations of the semantic meaning for each data record, which makes them compatible with vector search features.

1. Create an embedding for a search query and use it to perform a vector search on the vector store:

:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="72-88":::
:::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="Search":::

1. Use the `dotnet run` command to run the app:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.SemanticKernel.Connectors.InMemory;
using VectorDataAI;

// <SnippetDataSet>
var cloudServices = new List<CloudService>()
{
new CloudService
Expand Down Expand Up @@ -45,7 +46,9 @@
Description="Information retrieval at scale for traditional and conversational search applications, with security and options for AI enrichment and vectorization."
}
};
// </SnippetDataSet>

// <SnippetEmbeddingGen>
// Load the configuration values
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
string endpoint = config["AZURE_OPENAI_ENDPOINT"];
Expand All @@ -57,7 +60,9 @@
new Uri(endpoint),
new DefaultAzureCredential())
.AsEmbeddingGenerator(modelId: model);
// </SnippetEmbeddingGen>

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

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