Class PostgresPlugin

java.lang.Object
com.google.genkit.plugins.postgresql.PostgresPlugin
All Implemented Interfaces:
Plugin

public class PostgresPlugin extends Object implements Plugin
PostgreSQL plugin for Genkit providing vector database functionality using pgvector.

Example usage:


 Genkit genkit = Genkit
 		.builder().plugin(
 				GoogleGenAIPlugin.create(apiKey))
 		.plugin(PostgresPlugin.builder().connectionString("jdbc:postgresql://localhost:5432/mydb").username("user")
 				.password("pass").addTable(PostgresTableConfig.builder().tableName("documents")
 						.embedderName("googleai/text-embedding-004").build())
 				.build())
 		.build();
 
  • Method Details

    • builder

      public static PostgresPlugin.Builder builder()
      Creates a new builder for PostgresPlugin.
    • getName

      public String getName()
      Description copied from interface: Plugin
      Returns the unique identifier for the plugin. This name is used for registration and lookup.
      Specified by:
      getName in interface Plugin
      Returns:
      the plugin name
    • init

      public List<Action<?,?,?>> init()
      Description copied from interface: Plugin
      Initializes the plugin. This method is called once during Genkit initialization. The plugin should return a list of actions that it provides.
      Specified by:
      init in interface Plugin
      Returns:
      list of actions provided by this plugin
    • init

      public List<Action<?,?,?>> init(Registry registry)
      Description copied from interface: Plugin
      Initializes the plugin with access to the registry. This method is called once during Genkit initialization. The plugin should return a list of actions that it provides.

      Override this method instead of Plugin.init() when your plugin needs to resolve dependencies from the registry (e.g., embedders, models).

      Specified by:
      init in interface Plugin
      Parameters:
      registry - the Genkit registry for resolving dependencies
      Returns:
      list of actions provided by this plugin
    • getVectorStore

      public PostgresVectorStore getVectorStore(String tableName)
      Gets a vector store by table name.
      Parameters:
      tableName - the table name
      Returns:
      the vector store, or null if not found
    • close

      public void close()
      Closes the plugin and releases resources.