Documentation
¶
Index ¶
- Constants
- Variables
- func CloneMetadata(in map[string]any) map[string]any
- func CloneVector(in []float32) []float32
- func EmbeddingErrorCode(err error) string
- func NormalizeTopK(topK int) int
- func ValidateDimension(dimension int) error
- func ValidateKey(key string) error
- func ValidateRequiredMetadata(metadata map[string]any, required []string) error
- func ValidateVector(vector []float32, dimension int) error
- type BedrockRuntimeAPI
- type Call
- type DeleteInput
- type Embedder
- type Error
- type FakeEmbedder
- type FakeStore
- func (s *FakeStore) Calls() []Call
- func (s *FakeStore) DeleteVectors(_ context.Context, input DeleteInput) error
- func (s *FakeStore) GetVectors(_ context.Context, input GetInput) ([]VectorRecord, error)
- func (s *FakeStore) PutVectors(_ context.Context, input PutInput) error
- func (s *FakeStore) QueryVectors(_ context.Context, input QueryInput) ([]QueryHit, error)
- func (s *FakeStore) SetError(operation string, err error)
- type GetInput
- type PutInput
- type QueryHit
- type QueryInput
- type S3VectorStore
- func (s *S3VectorStore) DeleteVectors(ctx context.Context, input DeleteInput) error
- func (s *S3VectorStore) GetVectors(ctx context.Context, input GetInput) ([]VectorRecord, error)
- func (s *S3VectorStore) PutVectors(ctx context.Context, input PutInput) error
- func (s *S3VectorStore) QueryVectors(ctx context.Context, input QueryInput) ([]QueryHit, error)
- type S3VectorsAPI
- type SemanticIndex
- type SemanticRecord
- type Store
- type TitanEmbedder
- type VectorRecord
Constants ¶
View Source
const ( ErrorCodeInvalidConfig = "vectorstore.invalid_config" ErrorCodeInvalidInput = "vectorstore.invalid_input" ErrorCodeInvalidVector = "vectorstore.invalid_vector" ErrorCodeDimensionMismatch = "vectorstore.dimension_mismatch" ErrorCodeNotFound = "vectorstore.not_found" ErrorCodeUnsupportedOperation = "vectorstore.unsupported_operation" ErrorCodeEmbeddingFailed = "vectorstore.embedding_failed" )
View Source
const ( EnvVectorBucketName = "APPTHEORY_VECTOR_BUCKET_NAME" EnvVectorIndexName = "APPTHEORY_VECTOR_INDEX_NAME" EnvVectorIndexARN = "APPTHEORY_VECTOR_INDEX_ARN" EnvVectorDimension = "APPTHEORY_VECTOR_DIMENSION" EnvEmbeddingProvider = "APPTHEORY_EMBEDDING_PROVIDER" EnvEmbeddingModelID = "APPTHEORY_EMBEDDING_MODEL_ID" EnvEmbeddingDimensions = "APPTHEORY_EMBEDDING_DIMENSIONS" EnvEmbeddingNormalize = "APPTHEORY_EMBEDDING_NORMALIZE" DefaultTitanEmbedTextModelID = "amazon.titan-embed-text-v2:0" )
View Source
const ( DefaultEmbeddingDimensions = 1024 DefaultQueryTopK = 12 MaxQueryTopK = 10000 MaxPutDeleteBatchSize = 500 )
Variables ¶
View Source
var ( ErrInvalidConfig = &Error{Code: ErrorCodeInvalidConfig, Message: "vectorstore: invalid config"} ErrInvalidInput = &Error{Code: ErrorCodeInvalidInput, Message: "vectorstore: invalid input"} ErrInvalidVector = &Error{Code: ErrorCodeInvalidVector, Message: "vectorstore: invalid vector"} ErrDimensionMismatch = &Error{Code: ErrorCodeDimensionMismatch, Message: "vectorstore: vector dimension mismatch"} ErrNotFound = &Error{Code: ErrorCodeNotFound, Message: "vectorstore: vector not found"} ErrUnsupportedOperation = &Error{Code: ErrorCodeUnsupportedOperation, Message: "vectorstore: unsupported operation"} ErrEmbeddingFailed = &Error{Code: ErrorCodeEmbeddingFailed, Message: "vectorstore: embedding failed"} )
Functions ¶
func CloneVector ¶
func EmbeddingErrorCode ¶
func NormalizeTopK ¶
func ValidateDimension ¶
func ValidateKey ¶
func ValidateVector ¶
Types ¶
type BedrockRuntimeAPI ¶
type BedrockRuntimeAPI interface {
InvokeModel(context.Context, *bedrockruntime.InvokeModelInput, ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error)
}
type DeleteInput ¶
type DeleteInput struct {
Keys []string
}
type FakeEmbedder ¶
func NewFakeEmbedder ¶
func NewFakeEmbedder(embeddings map[string][]float32) *FakeEmbedder
func (*FakeEmbedder) EmbedBatch ¶
type FakeStore ¶
type FakeStore struct {
Dimension int
RequiredMetadataKeys []string
// contains filtered or unexported fields
}
func NewFakeStore ¶
func (*FakeStore) DeleteVectors ¶
func (s *FakeStore) DeleteVectors(_ context.Context, input DeleteInput) error
func (*FakeStore) GetVectors ¶
func (*FakeStore) PutVectors ¶
func (*FakeStore) QueryVectors ¶
type PutInput ¶
type PutInput struct {
Records []VectorRecord
}
type QueryInput ¶
type S3VectorStore ¶
type S3VectorStore struct {
Client S3VectorsAPI
VectorBucketName string
IndexName string
Dimension int
MaxBatchSize int
}
func NewS3VectorStore ¶
func (*S3VectorStore) DeleteVectors ¶
func (s *S3VectorStore) DeleteVectors(ctx context.Context, input DeleteInput) error
func (*S3VectorStore) GetVectors ¶
func (s *S3VectorStore) GetVectors(ctx context.Context, input GetInput) ([]VectorRecord, error)
func (*S3VectorStore) PutVectors ¶
func (s *S3VectorStore) PutVectors(ctx context.Context, input PutInput) error
func (*S3VectorStore) QueryVectors ¶
func (s *S3VectorStore) QueryVectors(ctx context.Context, input QueryInput) ([]QueryHit, error)
type S3VectorsAPI ¶
type S3VectorsAPI interface {
PutVectors(context.Context, *s3vectors.PutVectorsInput, ...func(*s3vectors.Options)) (*s3vectors.PutVectorsOutput, error)
QueryVectors(context.Context, *s3vectors.QueryVectorsInput, ...func(*s3vectors.Options)) (*s3vectors.QueryVectorsOutput, error)
GetVectors(context.Context, *s3vectors.GetVectorsInput, ...func(*s3vectors.Options)) (*s3vectors.GetVectorsOutput, error)
DeleteVectors(context.Context, *s3vectors.DeleteVectorsInput, ...func(*s3vectors.Options)) (*s3vectors.DeleteVectorsOutput, error)
}
type SemanticIndex ¶
type SemanticIndex struct {
Store Store
Embedder Embedder
Dimension int
RequiredMetadataKeys []string
}
func (*SemanticIndex) PutText ¶
func (i *SemanticIndex) PutText(ctx context.Context, records []SemanticRecord) error
func (*SemanticIndex) QueryText ¶
func (i *SemanticIndex) QueryText(ctx context.Context, text string, input QueryInput) ([]QueryHit, error)
type TitanEmbedder ¶
type TitanEmbedder struct {
Runtime BedrockRuntimeAPI
ModelID string
Dimensions int
Normalize bool
BatchConcurrency int
}
func NewTitanEmbedder ¶
func NewTitanEmbedder(ctx context.Context) (*TitanEmbedder, error)
func (*TitanEmbedder) EmbedBatch ¶
Click to show internal directories.
Click to hide internal directories.