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 RedisConfig
- type RedisStore
- func (s *RedisStore) Add(ctx context.Context, namespace string, id string, embedding []float32, ...) error
- func (s *RedisStore) Close(ctx context.Context, namespace string) error
- func (s *RedisStore) CreateNamespace(ctx context.Context, namespace string, dimension int, ...) error
- func (s *RedisStore) Delete(ctx context.Context, namespace string, id string) error
- func (s *RedisStore) DeleteAll(ctx context.Context, namespace string, queries []Query) ([]DeleteResult, error)
- func (s *RedisStore) DeleteNamespace(ctx context.Context, namespace string) error
- func (s *RedisStore) GetAll(ctx context.Context, namespace string, queries []Query, selectFields []string, ...) ([]SearchResult, *string, error)
- func (s *RedisStore) GetChunk(ctx context.Context, namespace string, id string) (SearchResult, error)
- func (s *RedisStore) GetChunks(ctx context.Context, namespace string, ids []string) ([]SearchResult, error)
- func (s *RedisStore) GetNearest(ctx context.Context, namespace string, vector []float32, queries []Query, ...) ([]SearchResult, error)
- type SearchResult
- type VectorStore
- type VectorStoreProperties
- type VectorStorePropertyType
- type VectorStoreType
- type WeaviateConfig
- type WeaviateGrpcConfig
- type WeaviateStore
- func (s *WeaviateStore) Add(ctx context.Context, className string, id string, embedding []float32, ...) error
- func (s *WeaviateStore) Close(ctx context.Context, className string) error
- func (s *WeaviateStore) CreateNamespace(ctx context.Context, className string, dimension int, ...) error
- func (s *WeaviateStore) Delete(ctx context.Context, className string, id string) error
- func (s *WeaviateStore) DeleteAll(ctx context.Context, className string, queries []Query) ([]DeleteResult, error)
- func (s *WeaviateStore) DeleteNamespace(ctx context.Context, className string) error
- func (s *WeaviateStore) GetAll(ctx context.Context, className string, queries []Query, selectFields []string, ...) ([]SearchResult, *string, error)
- func (s *WeaviateStore) GetChunk(ctx context.Context, className string, id string) (SearchResult, error)
- func (s *WeaviateStore) GetChunks(ctx context.Context, className string, ids []string) ([]SearchResult, error)
- func (s *WeaviateStore) GetNearest(ctx context.Context, className string, vector []float32, queries []Query, ...) ([]SearchResult, error)
Constants ¶
const (
// defaultLimit is the default limit used for pagination and batch operations
BatchLimit = 100
)
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.4
type DeleteResult struct { ID string Status DeleteStatus Error string }
DeleteResult represents the result of a delete operation.
type DeleteStatus ¶ added in v1.0.4
type DeleteStatus string
const ( DeleteStatusSuccess DeleteStatus = "success" DeleteStatusError DeleteStatus = "error" )
type Query ¶ added in v1.0.4
type Query struct { Field string Operator QueryOperator Value interface{} }
Query represents a query to the vector store.
type QueryOperator ¶ added in v1.0.4
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 RedisConfig ¶
type RedisConfig struct { // Connection settings Addr string `json:"addr"` // Redis server address (host:port) - REQUIRED Username string `json:"username,omitempty"` // Username for Redis AUTH (optional) Password string `json:"password,omitempty"` // Password for Redis AUTH (optional) DB int `json:"db,omitempty"` // Redis database number (default: 0) // Connection pool and timeout settings (passed directly to Redis client) PoolSize int `json:"pool_size,omitempty"` // Maximum number of socket connections (optional) MaxActiveConns int `json:"max_active_conns,omitempty"` // Maximum number of active connections (optional) MinIdleConns int `json:"min_idle_conns,omitempty"` // Minimum number of idle connections (optional) MaxIdleConns int `json:"max_idle_conns,omitempty"` // Maximum number of idle connections (optional) ConnMaxLifetime time.Duration `json:"conn_max_lifetime,omitempty"` // Connection maximum lifetime (optional) ConnMaxIdleTime time.Duration `json:"conn_max_idle_time,omitempty"` // Connection maximum idle time (optional) DialTimeout time.Duration `json:"dial_timeout,omitempty"` // Timeout for socket connection (optional) ReadTimeout time.Duration `json:"read_timeout,omitempty"` // Timeout for socket reads (optional) WriteTimeout time.Duration `json:"write_timeout,omitempty"` // Timeout for socket writes (optional) ContextTimeout time.Duration `json:"context_timeout,omitempty"` // Timeout for Redis operations (optional) }
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore represents the Redis vector store.
func (*RedisStore) CreateNamespace ¶ added in v1.0.17
func (s *RedisStore) CreateNamespace(ctx context.Context, namespace string, dimension int, properties map[string]VectorStoreProperties) error
func (*RedisStore) DeleteAll ¶ added in v1.0.17
func (s *RedisStore) DeleteAll(ctx context.Context, namespace string, queries []Query) ([]DeleteResult, error)
func (*RedisStore) DeleteNamespace ¶ added in v1.0.17
func (s *RedisStore) DeleteNamespace(ctx context.Context, namespace string) error
func (*RedisStore) GetChunk ¶
func (s *RedisStore) GetChunk(ctx context.Context, namespace string, id string) (SearchResult, error)
func (*RedisStore) GetChunks ¶
func (s *RedisStore) GetChunks(ctx context.Context, namespace string, ids []string) ([]SearchResult, error)
func (*RedisStore) GetNearest ¶ added in v1.0.17
type SearchResult ¶ added in v1.0.4
SearchResult represents a search result with metadata.
type VectorStore ¶
type VectorStore interface { CreateNamespace(ctx context.Context, namespace string, dimension int, properties map[string]VectorStoreProperties) error DeleteNamespace(ctx context.Context, namespace string) error GetChunk(ctx context.Context, namespace string, id string) (SearchResult, error) GetChunks(ctx context.Context, namespace string, ids []string) ([]SearchResult, error) GetAll(ctx context.Context, namespace string, queries []Query, selectFields []string, cursor *string, limit int64) ([]SearchResult, *string, error) GetNearest(ctx context.Context, namespace string, vector []float32, queries []Query, selectFields []string, threshold float64, limit int64) ([]SearchResult, error) Add(ctx context.Context, namespace string, id string, embedding []float32, metadata map[string]interface{}) error Delete(ctx context.Context, namespace string, id string) error DeleteAll(ctx context.Context, namespace string, queries []Query) ([]DeleteResult, error) Close(ctx context.Context, namespace string) 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 VectorStoreProperties ¶ added in v1.0.6
type VectorStoreProperties struct { DataType VectorStorePropertyType `json:"data_type"` Description string `json:"description"` }
type VectorStorePropertyType ¶ added in v1.0.6
type VectorStorePropertyType string
const ( VectorStorePropertyTypeString VectorStorePropertyType = "string" VectorStorePropertyTypeInteger VectorStorePropertyType = "integer" VectorStorePropertyTypeBoolean VectorStorePropertyType = "boolean" VectorStorePropertyTypeStringArray VectorStorePropertyType = "string[]" )
type VectorStoreType ¶
type VectorStoreType string
const ( VectorStoreTypeWeaviate VectorStoreType = "weaviate" VectorStoreTypeRedis VectorStoreType = "redis" )
type WeaviateConfig ¶ added in v1.0.4
type WeaviateConfig struct { // Connection settings Scheme string `json:"scheme"` // "http" or "https" - REQUIRED Host string `json:"host"` // "localhost:8080" - REQUIRED GrpcConfig *WeaviateGrpcConfig `json:"grpc_config,omitempty"` // grpc config for weaviate (optional) // 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) }
WeaviateConfig represents the configuration for the Weaviate vector store.
type WeaviateGrpcConfig ¶ added in v1.0.6
type WeaviateGrpcConfig struct { // Host is the host of the weaviate server (host:port). // If host is without a port number then the 80 port for insecured and 443 port for secured connections will be used. Host string `json:"host"` // Secured is a boolean flag indicating if the connection is secured Secured bool `json:"secured"` }
type WeaviateStore ¶ added in v1.0.4
type WeaviateStore struct {
// contains filtered or unexported fields
}
WeaviateStore represents the Weaviate vector store.
func (*WeaviateStore) Add ¶ added in v1.0.4
func (s *WeaviateStore) Add(ctx context.Context, className string, 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.4
func (s *WeaviateStore) Close(ctx context.Context, className string) error
func (*WeaviateStore) CreateNamespace ¶ added in v1.0.6
func (s *WeaviateStore) CreateNamespace(ctx context.Context, className string, dimension int, properties map[string]VectorStoreProperties) error
func (*WeaviateStore) DeleteAll ¶ added in v1.0.4
func (s *WeaviateStore) DeleteAll(ctx context.Context, className string, queries []Query) ([]DeleteResult, error)
func (*WeaviateStore) DeleteNamespace ¶ added in v1.0.13
func (s *WeaviateStore) DeleteNamespace(ctx context.Context, className string) error
func (*WeaviateStore) GetAll ¶ added in v1.0.4
func (s *WeaviateStore) GetAll(ctx context.Context, className string, queries []Query, selectFields []string, cursor *string, limit int64) ([]SearchResult, *string, error)
GetAll with filtering + pagination
func (*WeaviateStore) GetChunk ¶ added in v1.0.4
func (s *WeaviateStore) GetChunk(ctx context.Context, className string, id string) (SearchResult, error)
GetChunk returns the "metadata" for a single key
func (*WeaviateStore) GetChunks ¶ added in v1.0.4
func (s *WeaviateStore) GetChunks(ctx context.Context, className string, ids []string) ([]SearchResult, error)
GetChunks returns multiple objects by ID
func (*WeaviateStore) GetNearest ¶ added in v1.0.4
func (s *WeaviateStore) GetNearest( ctx context.Context, className string, vector []float32, queries []Query, selectFields []string, threshold float64, limit int64, ) ([]SearchResult, error)
GetNearest with explicit filters only