go-rag/collections.go
Snider d188b05ad8
Some checks failed
Security Scan / security (push) Successful in 10s
Test / test (push) Failing after 39s
feat: modernise to Go 1.26 iterators and stdlib helpers
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>
2026-02-23 05:36:39 +00:00

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)
}