Documentation
¶
Overview ¶
Package vectorstore provides a generic interface for vector stores.
Index ¶
- Constants
- Variables
- type Config
- type DeleteResult
- type DeleteStatus
- type Query
- type QueryOperator
- type SearchResult
- type VectorStore
- type VectorStoreType
- type WeaviateConfig
- type WeaviateProperties
- type WeaviateStore
- func (s *WeaviateStore) Add(ctx context.Context, id string, embedding []float32, ...) error
- func (s *WeaviateStore) Close(ctx context.Context) error
- func (s *WeaviateStore) Delete(ctx context.Context, id string) error
- func (s *WeaviateStore) DeleteAll(ctx context.Context, queries []Query) ([]DeleteResult, error)
- func (s *WeaviateStore) GetAll(ctx context.Context, queries []Query, selectFields []string, cursor *string, ...) ([]SearchResult, *string, error)
- func (s *WeaviateStore) GetChunk(ctx context.Context, id string) (SearchResult, error)
- func (s *WeaviateStore) GetChunks(ctx context.Context, ids []string) ([]SearchResult, error)
- func (s *WeaviateStore) GetNearest(ctx context.Context, vector []float32, queries []Query, selectFields []string, ...) ([]SearchResult, error)
Constants ¶
const (
// Default class names (Weaviate prefers PascalCase)
DefaultClassName = "BifrostStore"
)
Default values for Weaviate vector index configuration
Variables ¶
var ( ErrNotFound = errors.New("vectorstore: not found") ErrNotSupported = errors.New("vectorstore: operation not supported on this store") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool `json:"enabled"`
Type VectorStoreType `json:"type"`
Config any `json:"config"`
}
Config represents the configuration for the vector store.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON unmarshals the config from JSON.
type DeleteResult ¶ added in v1.0.3
type DeleteResult struct {
ID string
Status DeleteStatus
Error string
}
DeleteResult represents the result of a delete operation.
type DeleteStatus ¶ added in v1.0.3
type DeleteStatus string
const ( DeleteStatusSuccess DeleteStatus = "success" DeleteStatusError DeleteStatus = "error" )
type Query ¶ added in v1.0.3
type Query struct {
Field string
Operator QueryOperator
Value interface{}
}
Query represents a query to the vector store.
type QueryOperator ¶ added in v1.0.3
type QueryOperator string
const ( QueryOperatorEqual QueryOperator = "Equal" QueryOperatorNotEqual QueryOperator = "NotEqual" QueryOperatorGreaterThan QueryOperator = "GreaterThan" QueryOperatorLessThan QueryOperator = "LessThan" QueryOperatorGreaterThanOrEqual QueryOperator = "GreaterThanOrEqual" QueryOperatorLessThanOrEqual QueryOperator = "LessThanOrEqual" QueryOperatorLike QueryOperator = "Like" QueryOperatorContainsAny QueryOperator = "ContainsAny" QueryOperatorContainsAll QueryOperator = "ContainsAll" QueryOperatorIsNull QueryOperator = "IsNull" QueryOperatorIsNotNull QueryOperator = "IsNotNull" )
type SearchResult ¶ added in v1.0.3
SearchResult represents a search result with metadata.
type VectorStore ¶
type VectorStore interface {
GetChunk(ctx context.Context, id string) (SearchResult, error)
GetChunks(ctx context.Context, ids []string) ([]SearchResult, error)
GetAll(ctx context.Context, queries []Query, selectFields []string, cursor *string, count int64) ([]SearchResult, *string, error)
GetNearest(ctx context.Context, vector []float32, queries []Query, selectFields []string, threshold float64, limit int64) ([]SearchResult, error)
Add(ctx context.Context, id string, embedding []float32, metadata map[string]interface{}) error
Delete(ctx context.Context, id string) error
DeleteAll(ctx context.Context, queries []Query) ([]DeleteResult, error)
Close(ctx context.Context) error
}
VectorStore represents the interface for the vector store.
func NewVectorStore ¶
func NewVectorStore(ctx context.Context, config *Config, logger schemas.Logger) (VectorStore, error)
NewVectorStore returns a new vector store based on the configuration.
type VectorStoreType ¶
type VectorStoreType string
const (
VectorStoreTypeWeaviate VectorStoreType = "weaviate"
)
type WeaviateConfig ¶ added in v1.0.3
type WeaviateConfig struct {
// Connection settings
Scheme string `json:"scheme"` // "http" or "https" - REQUIRED
Host string `json:"host"` // "localhost:8080" - REQUIRED
// Authentication settings (optional)
ApiKey string `json:"api_key,omitempty"` // API key for authentication
Headers map[string]string `json:"headers,omitempty"` // Additional headers
// Connection settings
Timeout time.Duration `json:"timeout,omitempty"` // Request timeout (optional)
// Class name
ClassName string `json:"class_name,omitempty"`
// Select fields
Properties []WeaviateProperties `json:"properties,omitempty"`
}
WeaviateConfig represents the configuration for the Weaviate vector store.
type WeaviateProperties ¶ added in v1.0.3
type WeaviateStore ¶ added in v1.0.3
type WeaviateStore struct {
// contains filtered or unexported fields
}
WeaviateStore represents the Weaviate vector store.
func (*WeaviateStore) Add ¶ added in v1.0.3
func (s *WeaviateStore) Add(ctx context.Context, id string, embedding []float32, metadata map[string]interface{}) error
Add stores a new object (with or without embedding)
func (*WeaviateStore) Close ¶ added in v1.0.3
func (s *WeaviateStore) Close(ctx context.Context) error
func (*WeaviateStore) Delete ¶ added in v1.0.3
func (s *WeaviateStore) Delete(ctx context.Context, id string) error
Delete removes multiple objects by ID
func (*WeaviateStore) DeleteAll ¶ added in v1.0.3
func (s *WeaviateStore) DeleteAll(ctx context.Context, queries []Query) ([]DeleteResult, error)
func (*WeaviateStore) GetAll ¶ added in v1.0.3
func (s *WeaviateStore) GetAll(ctx context.Context, queries []Query, selectFields []string, cursor *string, count int64) ([]SearchResult, *string, error)
GetAll with filtering + pagination
func (*WeaviateStore) GetChunk ¶ added in v1.0.3
func (s *WeaviateStore) GetChunk(ctx context.Context, id string) (SearchResult, error)
GetChunk returns the "metadata" for a single key
func (*WeaviateStore) GetChunks ¶ added in v1.0.3
func (s *WeaviateStore) GetChunks(ctx context.Context, ids []string) ([]SearchResult, error)
GetChunks returns multiple objects by ID
func (*WeaviateStore) GetNearest ¶ added in v1.0.3
func (s *WeaviateStore) GetNearest( ctx context.Context, vector []float32, queries []Query, selectFields []string, threshold float64, limit int64, ) ([]SearchResult, error)
GetNearest with explicit filters only