Zum Inhalt

retriever

module wittgenstein_schema_discovery.retriever

SchemaRetriever — semantic retrieval of DDL and documentation from pgvector.

Queries the 'ddl' and 'documentation' LangChain PGVector collections and returns the top-k most relevant documents for a given question.

Replaces vn.get_related_ddl(question) and vn.get_related_documentation(question) from the Vanna 0.7.9 legacy stack.

Classes

  • SchemaRetriever — Retrieves DDL and documentation from pgvector for a natural-language question.

wittgenstein_schema_discovery.retriever.SchemaRetriever

class SchemaRetriever(connection_string: str, embedder: Embeddings)

Retrieves DDL and documentation from pgvector for a natural-language question.

Parameters

  • connection_string : str — psycopg3 URL for LangChain PGVector (e.g. 'postgresql+psycopg://user:pass@host/db').

  • embedder : Embeddings — any LangChain Embeddings instance.

Methods

Return the k most relevant DDL strings for the question.

Parameters

  • question : str — natural-language question or table name.

  • k : int — maximum number of DDL entries to return.

Returns

  • list[str] — List of DDL strings (CREATE TABLE ...).

Return the k most relevant documentation entries for the question.

Parameters

  • question : str — natural-language question or column/table name.

  • k : int — maximum number of documentation entries to return.

Returns

  • list[str] — List of documentation strings.