-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Bug: Plugin created by VectorStoreTextSearch.CreateWithGetTextSearchResults is not returning the results from the IVectorStore #9762
Comments
Hi @thomashauser Did you create your own |
Objects from VectorSearch Results should be transformed/mapped to TextSearchResult. This should solve issue. var result = new VectorStoreTextSearch<DataModel>(vectorStoreRecordCollection, textEmbeddingGeneration, stringMapper, resultMapper);
protected sealed class DataModelTextSearchStringMapper : ITextSearchStringMapper
{
/// <inheritdoc />
public string MapFromResultToString(object result)
{
if (result is DataModel dataModel)
{
return dataModel.Text;
}
throw new ArgumentException("Invalid result type.");
}
}
/// <summary>
/// Result mapper which converts a DataModel to a TextSearchResult.
/// </summary>
protected sealed class DataModelTextSearchResultMapper : ITextSearchResultMapper
{
/// <inheritdoc />
public TextSearchResult MapFromResultToTextSearchResult(object result)
{
if (result is DataModel dataModel)
{
return new TextSearchResult(value: dataModel.Text) { Name = dataModel.Key.ToString(), Link = dataModel.Link };
}
throw new ArgumentException("Invalid result type.");
}
} |
Yes, it's my own implementation. There is currently no version that supports IVectoreStore and not the deprecated kernel memory, right? |
Awesome that worked. Thanks |
Describe the bug
The method VectorizableTextSearchAsync is returning to document chunks, but the plugin said it is empty.
To Reproduce
ITextEmbeddingGenerationService textEmbeddingGenerationService = new OpenAITextEmbeddingGenerationService("text-embedding-small", openAiClient);
IVectorStore vectorStore = new SqlServerVectorStore(connectionString)
.UseTextEmbeddingGenerationService(textEmbeddingGenerationService);
var globalVectorStoreRecordCollection = vectorStore.GetCollection<int, DocumentRecord>("Global");
await globalVectorStoreRecordCollection.CreateCollectionIfNotExistsAsync();
var chatVectorStoreRecordCollection = vectorStore.GetCollection<int, DocumentRecord>($"Chat{chatId}");
await chatVectorStoreRecordCollection.CreateCollectionIfNotExistsAsync();
var globalSearch = new VectorStoreTextSearch(globalVectorStoreRecordCollection, textEmbeddingGenerationService);
var chatSearch = new VectorStoreTextSearch(chatVectorStoreRecordCollection, textEmbeddingGenerationService);
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(MODEL, azureOpenAIClient: openAiClient);
builder.Services.AddLogging(services => services.AddConsole().SetMinimumLevel(LogLevel.Trace));
var kernel = builder.Build();
// Add the plugin to the kernel
kernel.Plugins.Add(globalSearch.CreateWithGetTextSearchResults(nameof(globalSearch)));
kernel.Plugins.Add(chatSearch.CreateWithGetTextSearchResults(nameof(chatSearch)));
// Retrieve the chat completion service
var chatCompletionService = kernel.Services.GetRequiredService();
Expected behavior
The kernel should receive the two found document chunks.
Screenshots
Platform
Azure.AI.DocumentIntelligence: 1.0.0-beta.3
Microsoft.Extensions.Configuration.Json: 9.0.0
Microsoft.Extensions.Configuration.UserSecrets: 9.0.0
Microsoft.Extensions.DependencyInjection: 9.0.0
Microsoft.Extensions.Logging.Console: 9.0.0
Microsoft.Extensions.VectorData.Abstractions: 9.0.0-preview.1.24523.1
Microsoft.SemanticKernel: 1.29.0
Microsoft.SemanticKernel.Connectors.SqlServer: 1.29.0-alpha
Microsoft.SemanticKernel.Plugins.Core: 1.29.0-alpha
Microsoft.SemanticKernel.Plugins.Document: 1.29.0-alpha
Microsoft.SemanticKernel.Plugins.Memory: 1.29.0-alpha
Microsoft.Data.SqlClient: 5.2.2
Microsoft.SemanticKernel.Abstractions: 1.29.0
Microsoft.SemanticKernel.Connectors.AzureOpenAI: 1.29.0
Microsoft.SemanticKernel.Connectors.OpenAI: 1.29.0
System.Linq.Async: 6.0.1
The text was updated successfully, but these errors were encountered: