Retrieval Layer

The Retrieval Layer integrates vector stores with conversational AI frameworks (like LangChain and LangGraph), allowing AI agents to query database updates.

Module Summary

create_retriever_tool

Create a LangChain Tool backed by the VectorStoreAdapter.

create_retriever_node

Create a LangGraph-compatible node that queries the VectorStoreAdapter.

API Reference

LangGraph integration for PyDebeziumAI vector store adapters.

create_retriever_tool(adapter, name, description, **kwargs)[source]

Create a LangChain Tool backed by the VectorStoreAdapter.

This tool is designed to be passed to LangGraph agents or standard LangChain agent executors.

Parameters:
  • adapter (VectorStoreAdapter) – The VectorStoreAdapter instance to query.

  • name (str) – Name of the tool.

  • description (str) – Description of what the tool does and when to call it.

  • **kwargs (Any) – Additional parameters passed to adapter.as_retriever().

Returns:

A LangChain Tool instance.

Return type:

BaseTool

create_retriever_node(adapter, state_key='documents', query_key='query', query_extractor=None, **retriever_kwargs)[source]

Create a LangGraph-compatible node that queries the VectorStoreAdapter.

This node executes the retrieval query and updates the graph state with the resulting list of Document objects under the specified state_key.

Parameters:
  • adapter (VectorStoreAdapter) – The VectorStoreAdapter instance.

  • state_key (str) – The key in the returned state dictionary where retrieved documents will be stored.

  • query_key (str) – The key in the input state where the search query string is stored. Only used if query_extractor is None.

  • query_extractor (Callable[[Any], str] | None) – An optional callable that extracts the query string from the graph state. If provided, it overrides query_key.

  • **retriever_kwargs (Any) – Options passed to adapter.as_retriever() (e.g. search_kwargs).

Returns:

A callable node function for LangGraph.

Return type:

Callable[[Any], dict[str, Any]]