{"modulePath":"github.com/firebase/genkit/go","version":"v1.14.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package postgresql\n\n## Functions\n\n```go\nfunc Retriever(g *genkit.Genkit, id string) ai.Retriever\n```\nRetriever returns the retriever with the given index id.\n\n## Types\n\n```go\ntype BaseIndex struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewBaseIndex(indexName, indexType string, strategy DistanceStrategy, partialIndexes []string, opts Index) BaseIndex\n```\n\n```go\ntype Column struct {\n\tName     string\n\tDataType string\n\tNullable bool\n}\n```\n\n```go\ntype Config struct {\n\t// TableName the table name in which documents will be stored and searched.\n\tTableName string\n\t// SchemaName schema name in which documents will be stored and searched.\n\tSchemaName string\n\t// ContentColumn column name which contains content of the document. Defaults to content\n\tContentColumn string\n\t// EmbeddingColumn column name which contains the vector. Defaults to embedding\n\tEmbeddingColumn string\n\t// MetadataColumns a list of columns to create for custom metadata\n\tMetadataColumns []string\n\t// IDColumn column name which represents the identifier of the table. Defaults to id\n\tIDColumn string\n\t// MetadataJSONColumn the column to store extra metadata in JSON format\n\tMetadataJSONColumn string\n\t// IgnoreMetadataColumns column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns.\n\tIgnoreMetadataColumns []string\n\t// Embedder to use. Required.\n\tEmbedder ai.Embedder\n\t// EmbedderOptions options to pass to the Embedder.\n\tEmbedderOptions any\n}\n```\nConfig provides configuration options for [DefineRetriever](#DefineRetriever).\n\n```go\ntype CosineDistance struct{}\n```\n\n```go\nfunc (c CosineDistance) String() string\n```\n\n```go\ntype DistanceStrategy interface {\n\tString() string\n\t// contains filtered or unexported methods\n}\n```\n\n```go\ntype DocStore struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc DefineRetriever(ctx context.Context, g *genkit.Genkit, p *Postgres, cfg *Config) (*DocStore, ai.Retriever, error)\n```\nDefineRetriever defines a Retriever with the given configuration.\n\n```go\nfunc (ds *DocStore) Index(ctx context.Context, docs []*ai.Document) error\n```\nIndex implements the genkit.Index method.\n\n```go\nfunc (ds *DocStore) Retrieve(ctx context.Context, req *ai.RetrieverRequest) (*ai.RetrieverResponse, error)\n```\nRetrieve returns the result of the query\n\n```go\ntype Euclidean struct{}\n```\n\n```go\nfunc (e Euclidean) String() string\n```\n\n```go\ntype HNSWOptions struct {\n\tM              int\n\tEfConstruction int\n}\n```\nHNSWOptions holds the configuration for the hnsw index.\n\n```go\nfunc (h HNSWOptions) Options() string\n```\n\n```go\ntype IVFFlatOptions struct {\n\tLists int\n}\n```\nIVFFlatOptions holds the configuration for the ivfflat index.\n\n```go\nfunc (i IVFFlatOptions) Options() string\n```\n\n```go\ntype Index interface {\n\tOptions() string\n}\n```\n\n```go\ntype InnerProduct struct{}\n```\n\n```go\nfunc (i InnerProduct) String() string\n```\n\n```go\ntype IpType string\n```\nIpType type of IP address, public or private\n\n```go\nconst (\n\tPUBLIC  IpType = \"PUBLIC\"\n\tPRIVATE IpType = \"PRIVATE\"\n)\n```\n\n```go\ntype Option func(p *engineConfig)\n```\nOption is a function type that can be used to modify the Engine.\n\n```go\nfunc WithCloudSQLInstance(projectID, region, instance string) Option\n```\nWithCloudSQLInstance sets the project, region, and instance fields.\n\n```go\nfunc WithDatabase(database string) Option\n```\nWithDatabase sets the database to connect to. Required unless the engine uses a pool given with [WithPool](#WithPool).\n\n```go\nfunc WithIAMAccountEmail(email string) Option\n```\nWithIAMAccountEmail sets the IAMAccountEmail field.\n\n```go\nfunc WithIPType(ipType IpType) Option\n```\nWithIPType sets the IpType field.\n\n```go\nfunc WithPassword(password string) Option\n```\nWithPassword sets the Password field.\n\n```go\nfunc WithPool(pool *pgxpool.Pool) Option\n```\nWithPool gives the engine an existing connection pool, used as is: the engine dials nothing, needs no [WithDatabase](#WithDatabase), and leaves the pool open on Close.\n\n```go\nfunc WithUser(user string) Option\n```\nWithUser sets the User field.\n\n```go\ntype Postgres struct {\n\tEngine *PostgresEngine\n\t// contains filtered or unexported fields\n}\n```\nPostgres holds the current plugin state.\n\n```go\nfunc (p *Postgres) ApplyVectorIndex(ctx context.Context, config *Config, index BaseIndex, name string, concurrently bool) error\n```\nApplyVectorIndex creates an index in the table of the embeddings.\n\n```go\nfunc (p *Postgres) DropVectorIndex(ctx context.Context, config *Config, indexName string) error\n```\nDropVectorIndex drops the vector index from the table.\n\n```go\nfunc (p *Postgres) Init(ctx context.Context) []api.Action\n```\nInit initialize the PostgreSQL\n\n```go\nfunc (p *Postgres) IsValidIndex(ctx context.Context, config *Config, indexName string) (bool, error)\n```\nIsValidIndex checks if index exists in the table.\n\n```go\nfunc (p *Postgres) Name() string\n```\n\n```go\nfunc (p *Postgres) ReIndex(ctx context.Context, config *Config) error\n```\nReIndex recreates the index on the table.\n\n```go\nfunc (p *Postgres) ReIndexWithName(ctx context.Context, indexName string) error\n```\nReIndexWithName recreates the index on the table by name.\n\n```go\ntype PostgresEngine struct {\n\tPool *pgxpool.Pool\n\t// contains filtered or unexported fields\n}\n```\nPostgresEngine holds the connection pool the plugin's features share.\n\n```go\nfunc NewPostgresEngine(ctx context.Context, opts ...Option) (*PostgresEngine, error)\n```\nNewPostgresEngine creates a new Postgres Engine. It either uses the pool given with [WithPool](#WithPool) or dials the Cloud SQL instance given with [WithCloudSQLInstance](#WithCloudSQLInstance), and pings the database before returning.\n\n```go\nfunc (pgEngine *PostgresEngine) Close()\n```\nClose releases what the engine created: the pool [NewPostgresEngine](#NewPostgresEngine) built and the Cloud SQL dialer behind it. A pool given with [WithPool](#WithPool), or set on Pool directly, belongs to the caller, who closes it.\n\n```go\nfunc (pgEngine *PostgresEngine) GetClient() *pgxpool.Pool\n```\n\n```go\nfunc (pgEngine *PostgresEngine) InitVectorstoreTable(ctx context.Context, opts VectorstoreTableOptions) error\n```\ninitVectorstoreTable creates a table for saving of vectors to be used with PostgresVectorStore.\n\n```go\ntype RetrieverOptions struct {\n\t// Filter values to be used in the where clause. Defaults is nil\n\tFilter any\n\t// K the number of documents to return from search. Defaults to 4.\n\tK int\n\t// DistanceStrategy distance strategy to use for vector similarity search. Defaults to CosineDistance\n\tDistanceStrategy DistanceStrategy\n}\n```\nRetrieverOptions options for retriever\n\n```go\ntype VectorstoreTableOptions struct {\n\tTableName          string\n\tVectorSize         int\n\tSchemaName         string\n\tContentColumnName  string\n\tEmbeddingColumn    string\n\tMetadataJSONColumn string\n\tIDColumn           Column\n\tMetadataColumns    []Column\n\tOverwriteExisting  bool\n\tStoreMetadata      bool\n}\n```\n\n","path":"github.com/firebase/genkit/go/plugins/postgresql","name":"postgresql","synopsis":"","isRedistributable":true}
