-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
.Net: [Feature Branch] Vector Store Logging #10865
base: feature-vector-data-telemetry
Are you sure you want to change the base?
.Net: [Feature Branch] Vector Store Logging #10865
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some documentation updates (I didn't comment everywhere) and the question about adding the same instance twice.
dotnet/src/Connectors/VectorData.Abstractions/VectorSearch/KeywordHybridSearchBuilder.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/VectorData.Abstractions/VectorSearch/KeywordHybridSearchBuilder.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/VectorData/VectorSearch/KeywordHybridSearchBuilder.cs
Show resolved
Hide resolved
dotnet/src/Connectors/VectorData/VectorSearch/LoggingKeywordHybridSearchBuilderExtensions.cs
Show resolved
Hide resolved
dotnet/src/Connectors/VectorData/VectorSearch/LoggingVectorizableTextSearchBuilderExtensions.cs
Show resolved
Hide resolved
dotnet/src/Connectors/VectorData/VectorSearch/LoggingVectorizedSearchBuilderExtensions.cs
Show resolved
Hide resolved
|
||
// Register InMemoryVectorStore with enabled logging. | ||
serviceCollection | ||
.AddVectorStore(s => s.GetRequiredService<InMemoryVectorStore>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unfortunate. I wonder if we should just change AddInMemoryVectorStore to return the builder, or add an overload like AddInMemoryVectorStoreBuilder(), which returns the builder instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that, but connector developers will need to make sure that they have similar extension method available on their side. I think that method like AddVectorStore
is also useful for cases when there are no extension methods available for specific connector/abstraction implementation. There is an overload for this method to simply accept IVectorStore
instance.
For connectors that exist on our side at the moment, we can add an additional extension method to operate with builder, but I would probably do that in a separate PR to minimize the number of changes in this one. Please let me know what you think, thanks!
namespace Memory; | ||
|
||
/// <summary> | ||
/// A simple example showing how to ingest data into a vector store and then use vector search to find related records to a given string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do a sample around what this looks like for HybridSearch and VectorizableTextSearch.
Also, I think we may have some issues with cases where someone just created a VectorStoreRecordCollection instance and they want to add logging to it, and then they want to cast it to a VectorizableTextSearch and start searching and they expectation would be that logging would be there for it too...
It's almost like we might need a single decorator class that implements all the interfaces and contains all logging, although that has drawbacks too, in that someone can cast to an interface that the decorator has but the underlying implementation doesn't support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do a sample around what this looks like for HybridSearch and VectorizableTextSearch.
Yes, I'm definitely going to add that. It would be nice if we add an example for HybridSearch first, so then I can re-use that example to show how to enable logging, if possible :)
I think we may have some issues with cases where someone just created a VectorStoreRecordCollection instance and they want to add logging to it, and then they want to cast it to a VectorizableTextSearch and start searching and they expectation would be that logging would be there for it too
Do we think that casting would be a common approach here? Let's imagine we have an ASP.NET Web API application, and we have a service, that performs vector search using text. I would expect that this service will accept IVectorizableTextSearch<MyRecord>
in constructor and it's a matter of configuration which instance of that interface is going to be passed in the service and whether it supports logging or not. Same for other interfaces from VectorData.
In case of VectorStoreRecordCollection
which implements multiple interfaces, I think that user registers specific vector db collection once (like RedisVectorStoreRecordCollection), and then use it to register IVectorStoreRecordCollection
, IVectorizableTextSearch
and wrap each registration to support logging. I think it's really flexible approach that user can control where exactly logging or any other decoration is needed, but of course we can provide even more extension methods for easier usage (for example, the extension method that will register IVectorStore
, IVectorStoreRecordCollection
and IVectorizableTextSearch
with already enabled logging and so on).
Please let me know what you think about it.
Motivation and Context
Related: #10596
This PR enhances the vector store functionality by adding builder pattern implementations and logging decorators for key vector data interfaces, along with supporting utilities and DI integration.
Interfaces handled:
IKeywordHybridSearch<TRecord>
IVectorizableTextSearch<TRecord>
IVectorizedSearch<TRecord>
IVectorStore
IVectorStoreRecordCollection<TKey, TRecord>
Class types added:
Use
andBuild
methods.LoggingExtensions
reusable logging methods.AsBuilder
methods to convert service instances into builders.UseLogging
methods to integrate logging into builder pipelines.Add{T}
andAddKeyed{T}
methods for DI registration with configurable lifetimes.Other changes:
Verify
class intoVerify
andKernelVerify
in order to be able to useVerify
methods inMicrosoft.Extensions.VectorData
package without a reference to Semantic Kernel specific logic, likeValidPluginName
,ValidFunctionName
etc.Concepts/Memory
folder.Usage example
Logging with manual registration:
Logging with DI:
Contribution Checklist