Add ChunkMarkdownSeq, QuerySeq, KeywordFilterSeq, ListCollectionsSeq iterators for streaming. Use slices.SortFunc, slices.Contains, slices.Collect in mock/query/keyword. Range-over-int in benchmarks. Co-Authored-By: Gemini <noreply@google.com> Co-Authored-By: Virgil <virgil@lethean.io>
31 lines
977 B
Go
31 lines
977 B
Go
package rag
|
|
|
|
import (
|
|
"context"
|
|
"iter"
|
|
"slices"
|
|
)
|
|
|
|
// ListCollections returns all collection names from the given vector store.
|
|
func ListCollections(ctx context.Context, store VectorStore) ([]string, error) {
|
|
return store.ListCollections(ctx)
|
|
}
|
|
|
|
// ListCollectionsSeq returns an iterator that yields all collection names from the given vector store.
|
|
func ListCollectionsSeq(ctx context.Context, store VectorStore) (iter.Seq[string], error) {
|
|
names, err := store.ListCollections(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return slices.Values(names), nil
|
|
}
|
|
|
|
// DeleteCollection removes a collection from the given vector store.
|
|
func DeleteCollection(ctx context.Context, store VectorStore, name string) error {
|
|
return store.DeleteCollection(ctx, name)
|
|
}
|
|
|
|
// CollectionStats returns backend-agnostic metadata about a collection.
|
|
func CollectionStats(ctx context.Context, store VectorStore, name string) (*CollectionInfo, error) {
|
|
return store.CollectionInfo(ctx, name)
|
|
}
|