-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Aspire bits + update dependencies
- Loading branch information
1 parent
c2d6573
commit f828598
Showing
25 changed files
with
159 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
samples/support-center/SupportCenter.ApiService/Data/VectorRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Microsoft.Extensions.AI; | ||
using Microsoft.Extensions.VectorData; | ||
using System.Text; | ||
|
||
namespace SupportCenter.ApiService.Data | ||
{ | ||
public class VectorRepository(IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator, IVectorStore vectorStore) | ||
{ | ||
public async ValueTask<string> AddKnowledge(string query, string index, int top=2) | ||
{ | ||
var queryEmbedding = await embeddingGenerator.GenerateEmbeddingVectorAsync(query); | ||
var collection = vectorStore.GetCollection<int, Movie>(index); | ||
|
||
var searchOptions = new VectorSearchOptions() | ||
{ | ||
Top = top, | ||
VectorPropertyName = "Vector" | ||
}; | ||
|
||
var results = await collection.VectorizedSearchAsync(queryEmbedding, searchOptions); | ||
var kbStringBuilder = new StringBuilder(); | ||
//await foreach (var result in results.Results) | ||
//{ | ||
// kbStringBuilder.AppendLine($"{doc.Metadata.Text}"); | ||
//} | ||
//arguments[index] = instruction.Replace($"!{index}!", $"{kbStringBuilder}"); | ||
return ""; | ||
} | ||
} | ||
} | ||
|
||
|
||
public class Movie | ||
{ | ||
[VectorStoreRecordKey] | ||
public int Key { get; set; } | ||
|
||
[VectorStoreRecordData] | ||
public string Title { get; set; } | ||
|
||
[VectorStoreRecordData] | ||
public string Description { get; set; } | ||
|
||
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)] | ||
public ReadOnlyMemory<float> Vector { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.