Documentation
¶
Index ¶
- func Retriever(g *genkit.Genkit, name string) ai.Retriever
- type BaseIndex
- type Column
- type Config
- type CosineDistance
- type DistanceStrategy
- type DocStore
- type Euclidean
- type HNSWOptions
- type IVFFlatOptions
- type Index
- type InnerProduct
- type IpType
- type Option
- func WithAlloyDBInstance(projectID, region, cluster, instance string) Option
- func WithDatabase(database string) Option
- func WithIAMAccountEmail(email string) Option
- func WithIPType(ipType IpType) Option
- func WithPassword(password string) Option
- func WithPool(pool *pgxpool.Pool) Option
- func WithUser(user string) Option
- type Postgres
- func (p *Postgres) ApplyVectorIndex(ctx context.Context, config *Config, index BaseIndex, name string, ...) error
- func (p *Postgres) DropVectorIndex(ctx context.Context, config *Config, indexName string) error
- func (p *Postgres) Init(ctx context.Context, g *genkit.Genkit) error
- func (p *Postgres) IsValidIndex(ctx context.Context, config *Config, indexName string) (bool, error)
- func (p *Postgres) Name() string
- func (p *Postgres) ReIndex(ctx context.Context, config *Config) error
- func (p *Postgres) ReIndexWithName(ctx context.Context, indexName string) error
- type PostgresEngine
- type RetrieverOptions
- type VectorstoreTableOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseIndex ¶
type BaseIndex struct {
// contains filtered or unexported fields
}
func NewBaseIndex ¶
func NewBaseIndex(indexName, indexType string, strategy DistanceStrategy, partialIndexes []string, opts Index) BaseIndex
type Config ¶
type Config struct { // TableName the table name in which documents will be stored and searched. TableName string // SchemaName schema name in which documents will be stored and searched. SchemaName string // ContentColumn column name which contains content of the document ContentColumn string // EmbeddingColumn column name which contains the vector EmbeddingColumn string // MetadataColumns a list of columns to create for custom metadata MetadataColumns []string // IDColumn column name which represents the identifier of the table IDColumn string // MetadataJSONColumn the column to store extra metadata in JSON format MetadataJSONColumn string // IgnoreMetadataColumns column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns. IgnoreMetadataColumns []string // Embedder to use. Required. Embedder ai.Embedder // EmbedderOptions options to pass to the Embedder. EmbedderOptions any }
Config provides configuration options for DefineRetriever.
type CosineDistance ¶
type CosineDistance struct{}
func (CosineDistance) String ¶
func (c CosineDistance) String() string
type DistanceStrategy ¶
type DistanceStrategy interface { String() string // contains filtered or unexported methods }
type DocStore ¶
type DocStore struct {
// contains filtered or unexported fields
}
func DefineRetriever ¶
func DefineRetriever(ctx context.Context, g *genkit.Genkit, p *Postgres, cfg *Config) (*DocStore, ai.Retriever, error)
DefineRetriever defines a Retriever with the given configuration.
func (*DocStore) Retrieve ¶
func (ds *DocStore) Retrieve(ctx context.Context, req *ai.RetrieverRequest) (*ai.RetrieverResponse, error)
Retrieve returns the result of the query
type HNSWOptions ¶
HNSWOptions holds the configuration for the hnsw index.
func (HNSWOptions) Options ¶
func (h HNSWOptions) Options() string
type IVFFlatOptions ¶
type IVFFlatOptions struct {
Lists int
}
IVFFlatOptions holds the configuration for the ivfflat index.
func (IVFFlatOptions) Options ¶
func (i IVFFlatOptions) Options() string
type InnerProduct ¶
type InnerProduct struct{}
func (InnerProduct) String ¶
func (i InnerProduct) String() string
type Option ¶
type Option func(p *engineConfig)
Option is a function type that can be used to modify the Engine.
func WithAlloyDBInstance ¶
WithAlloyDBInstance sets the project, region, and instance fields.
func WithIAMAccountEmail ¶
WithIAMAccountEmail sets the IAMAccountEmail field.
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
Postgres holds the current plugin state.
func (*Postgres) ApplyVectorIndex ¶
func (p *Postgres) ApplyVectorIndex(ctx context.Context, config *Config, index BaseIndex, name string, concurrently bool) error
ApplyVectorIndex creates an index in the table of the embeddings.
func (*Postgres) DropVectorIndex ¶
DropVectorIndex drops the vector index from the table.
func (*Postgres) IsValidIndex ¶
func (p *Postgres) IsValidIndex(ctx context.Context, config *Config, indexName string) (bool, error)
IsValidIndex checks if index exists in the table.
type PostgresEngine ¶
PostgresEngine postgres engine
func NewPostgresEngine ¶
func NewPostgresEngine(ctx context.Context, opts ...Option) (*PostgresEngine, error)
NewPostgresEngine creates a new Postgres Engine.
func (*PostgresEngine) Close ¶
func (pgEngine *PostgresEngine) Close()
Close closes the pool connection.
func (*PostgresEngine) GetClient ¶
func (pgEngine *PostgresEngine) GetClient() *pgxpool.Pool
func (*PostgresEngine) InitVectorstoreTable ¶
func (pgEngine *PostgresEngine) InitVectorstoreTable(ctx context.Context, opts VectorstoreTableOptions) error
initVectorstoreTable creates a table for saving of vectors to be used with PostgresVectorStore.
type RetrieverOptions ¶
type RetrieverOptions struct { // Filter filter to be used in the where clause. Defaults is nil Filter any // K the number of documents to return from search. Defaults to 4. K int // DistanceStrategy distance strategy to use for vector similarity search. Defaults to CosineDistance DistanceStrategy DistanceStrategy }
RetrieverOptions options for retriever