yb-rag-langchain
Installation
SKILL.md
YugabyteDB + LangChain — Agent Guide
Use PGVectorStore (the v2 integration) for new RAG and hybrid-search applications. PGVector is the older integration. The examples below target langchain-postgres 0.0.17; check the installed release before relying on filtering or hybrid-search behavior.
Connection & dependencies
- For new deployments, use a supported YugabyteDB release with the required pgvector features; 2025.2 or later is the baseline for these examples. On an older release (2.20, 2.23, 2024.x), stop and advise an upgrade before debugging vector-index behavior:
ybhnswis either unavailable or subject to limitations fixed in later releases. Check the pgvector support and limitations for the deployed version before upgrading or troubleshooting an existing cluster. - YSQL normally listens on 5433. Use the actual configured endpoint.
langchain-postgresdeclares upstreampsycopg[binary]as a dependency; usepostgresql+psycopg://in SQLAlchemy URLs.- Check for the smart driver before installing RAG dependencies. Keep
psycopg-yugabytedbseparate from upstreampsycopg,psycopg-binary, andpsycopg-c. If present, preserve the working environment and surface the choice: isolate RAG in another environment/process, or explicitly migrate the shared workload to upstream psycopg. Before migrating, fetch the fork’s options and restrictions and upstream libpq options: remove or translate every fork-only setting and alias in connection strings and keyword arguments. Package replacement alone is not a migration. PGVectorStorerequires aPGEngine, not a raw connection string. The following is a local-development example; configure credentials and TLS for deployment.
from langchain_postgres import PGEngine, PGVectorStore
engine = PGEngine.from_connection_string(
"postgresql+psycopg://yugabyte:yugabyte@localhost:5433/yugabyte"
)