Skip to content
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
6 changes: 4 additions & 2 deletions docs/ai/quickstarts/build-vector-search-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ Complete the following steps to create a .NET console app that can:
dotnet add package Microsoft.SemanticKernel.Connectors.InMemory --prerelease
dotnet add package Microsoft.Extensions.Configuration
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
dotnet add package System.Linq.AsyncEnumerable
```

The following list describes what each package is used for in the `VectorDataAI` app:
The following list describes each package in the `VectorDataAI` app:

- [`Azure.Identity`](https://www.nuget.org/packages/Azure.Identity) provides [`Microsoft Entra ID`](/entra/fundamentals/whatis) token authentication support across the Azure SDK using classes such as `DefaultAzureCredential`.
- [`Azure.AI.OpenAI`](https://www.nuget.org/packages/Azure.AI.OpenAI) is the official package for using OpenAI's .NET library with the Azure OpenAI Service.
Expand All @@ -98,9 +99,10 @@ Complete the following steps to create a .NET console app that can:
dotnet add package Microsoft.SemanticKernel.Connectors.InMemory --prerelease
dotnet add package Microsoft.Extensions.Configuration
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
dotnet add package System.Linq.AsyncEnumerable
```

The following list describes what each package is used for in the `VectorDataAI` app:
The following list describes each package in the `VectorDataAI` app:

- [`Microsoft.Extensions.AI.OpenAI`](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI) provides AI abstractions for OpenAI-compatible models or endpoints. This library also includes the official [`OpenAI`](https://www.nuget.org/packages/OpenAI) library for the OpenAI service API as a dependency.
- [`Microsoft.SemanticKernel.Connectors.InMemory`](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.InMemory) provides an in-memory vector store class to hold queryable vector data records.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using Microsoft.Extensions.VectorData;

namespace VectorDataAI
namespace VectorDataAI;

internal class CloudService
{
internal class CloudService
{
[VectorStoreRecordKey]
public int Key { get; set; }
[VectorStoreRecordKey]
public int Key { get; set; }

[VectorStoreRecordData]
public string Name { get; set; }
[VectorStoreRecordData]
public string Name { get; set; }

[VectorStoreRecordData]
public string Description { get; set; }
[VectorStoreRecordData]
public string Description { get; set; }

[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
public ReadOnlyMemory<float> Vector { get; set; }
}
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
public ReadOnlyMemory<float> Vector { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class CloudService
[VectorStoreRecordData]
public string Description { get; set; }

[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
[VectorStoreRecordVector(Dimensions: 384, DistanceFunction = DistanceFunction.CosineSimilarity)]
public ReadOnlyMemory<float> Vector { get; set; }
}
}
14 changes: 5 additions & 9 deletions docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,20 @@

foreach (CloudService service in cloudServices)
{
service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description);
service.Vector = await generator.GenerateVectorAsync(service.Description);
await cloudServicesStore.UpsertAsync(service);
}

// 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);
ReadOnlyMemory<float> queryEmbedding = await generator.GenerateVectorAsync(query);

VectorSearchResults<CloudService> results =
await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions<CloudService>()
{
Top = 1
});
List<VectorSearchResult<CloudService>> results =
await cloudServicesStore.SearchEmbeddingAsync(queryEmbedding, top: 1).ToListAsync();

await foreach (VectorSearchResult<CloudService> result in results.Results)
foreach (VectorSearchResult<CloudService> result in results)
{
Console.WriteLine($"Name: {result.Record.Name}");
Console.WriteLine($"Description: {result.Record.Description}");
Console.WriteLine($"Vector match score: {result.Score}");
Console.WriteLine();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.4.0-preview.1.25207.5" />
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25161.1" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.41.0-preview" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.4.3-preview.1.25230.7" />
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25229.1" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.48.0-preview" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.3.25171.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0-preview.3.25171.5" />
<PackageReference Include="System.Linq.AsyncEnumerable" Version="10.0.0-preview.3.25171.5" />
</ItemGroup>

</Project>