Summary of entries of Classes for langchain-google-alloydb-pg.
Classes
AlloyDBChatMessageHistory
Chat message history stored in an AlloyDB for PostgreSQL database.
AlloyDBSaver
Checkpoint stored in an AlloyDB for PostgreSQL database.
AlloyDBDocumentCompressor
Reranks documents with AlloyDB AI's google_ml.rank() function.
The ranking runs inside the database through AlloyDB's Vertex AI
integration. model_id is required, for example
"semantic-ranker-default-003".
compressor = AlloyDBDocumentCompressor(
engine=engine, model_id="semantic-ranker-default-003", top_n=3
)
docs = compressor.compress_documents(documents, "What is AlloyDB?")
AlloyDBEmbeddings
Google AlloyDB Embeddings available via Model Endpoint Management.
AlloyDBEngine
A class for managing connections to a AlloyDB database.
IVFIndex
IVFIndex(name: Optional[str] = None, index_type: str = 'ivf', distance_strategy: langchain_postgres.v2.indexes.DistanceStrategy =
IVFQueryOptions
IVFQueryOptions(probes: int = 1)
ScaNNIndex
ScaNN index configuration for AlloyDB.
ScaNNQueryOptions
Query options for ScaNN index.
AlloyDBDocumentSaver
A class for saving langchain documents into a PostgreSQL database table.
AlloyDBLoader
Load documents from AlloyDB`.
Each document represents one row of the result. The content_columns are
written into the content_columns of the document. The metadata_columns are written
into the metadata_columns of the document. By default, first columns is written into
the page_content and everything else into the metadata.
AlloyDBModelManager
Manage models to be used with google_ml_integration Extension. Refer to Model Endpoint Management.
AlloyDBIfInput
Input for AlloyDBIfTool.
AlloyDBIfTool
Evaluates a natural-language condition with google_ml.if.
Returns True or False. Requires AlloyDB with
google_ml_integration. Like any LangChain tool, call it with
invoke / ainvoke or give it to an agent:
tool = AlloyDBIfTool(engine=engine)
tool.invoke({"condition": "Is 2 + 2 equal to 4?"}) # True
model_id works as in AlloyDBSentimentTool. If the model's
reply is neither true nor false, google_ml.if returns NULL and the
tool raises AlloyDBToolError rather than returning a value.
AlloyDBSentimentTool
Analyzes the sentiment of text with google_ml.analyze_sentiment.
Requires AlloyDB running PostgreSQL 17 or higher with
google_ml_integration. Like any LangChain tool, call it with
invoke / ainvoke or give it to an agent:
tool = AlloyDBSentimentTool(engine=engine)
tool.invoke({"content": "I love this product!"}) # "positive"
model_id is set on the tool, not by the agent. If it is None, the
database uses the model named by its
google_ml_integration.default_llm_model flag. If the function returns
NULL, the tool raises AlloyDBToolError.
AlloyDBSummaryTool
Summarizes text with google_ml.summarize.
Requires AlloyDB running PostgreSQL 17 or higher with
google_ml_integration. Like any LangChain tool, call it with
invoke / ainvoke or give it to an agent:
tool = AlloyDBSummaryTool(engine=engine)
tool.invoke(
{"content": article, "additional_instructions": "In 3 bullet points"}
)
model_id works as in AlloyDBSentimentTool: it is set on the
tool, and None uses the database's default model.
additional_instructions can be set on the tool or passed per call; a
per-call value replaces the tool's.
AlloyDBToolError
Raised when an AlloyDB AI function returns NULL.
That happens, for example, when the model's reply isn't one of the
expected answers. invoke / ainvoke raise this error like any
other. Because it is a ToolException, a tool created with
handle_tool_error=True returns its message to the agent instead.
Database errors (DBAPIError), such as an unknown model, always raise.
SentimentInput
Input for AlloyDBSentimentTool.
SummaryInput
Input for AlloyDBSummaryTool.
AlloyDBVectorStore
Google AlloyDB Vector Store class
Modules
chat_message_history
API documentation for chat_message_history module.
checkpoint
API documentation for checkpoint module.
document_compressor
API documentation for document_compressor module.
embeddings
API documentation for embeddings module.
engine
API documentation for engine module.
indexes
API documentation for indexes module.
loader
API documentation for loader module.
model_manager
API documentation for model_manager module.
tools
API documentation for tools module.
vectorstore
API documentation for vectorstore module.