Compare commits

..

2 Commits

Author SHA1 Message Date
Ryan Chen 564a9b68a5 Enable async_mode on PGVector for async method support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-24 08:53:21 -04:00
Ryan Chen c157c37cde Handle missing pgvector tables on first run
_get_collection_id now catches the UndefinedTable error that occurs
before the first index operation creates the langchain tables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-24 08:49:00 -04:00
+12 -7
View File
@@ -38,6 +38,7 @@ def _get_vector_store() -> PGVector:
connection=_pgvector_url, connection=_pgvector_url,
use_jsonb=True, use_jsonb=True,
create_extension=False, # created by docker init script create_extension=False, # created by docker init script
async_mode=True,
) )
return _vector_store return _vector_store
@@ -59,13 +60,17 @@ text_splitter = RecursiveCharacterTextSplitter(
def _get_collection_id(): def _get_collection_id():
"""Get the UUID of our collection from the langchain_pg_collection table.""" """Get the UUID of our collection from the langchain_pg_collection table."""
engine = _get_engine() engine = _get_engine()
with engine.connect() as conn: try:
result = conn.execute( with engine.connect() as conn:
text("SELECT uuid FROM langchain_pg_collection WHERE name = :name"), result = conn.execute(
{"name": "simba_docs"}, text("SELECT uuid FROM langchain_pg_collection WHERE name = :name"),
) {"name": "simba_docs"},
row = result.fetchone() )
return row[0] if row else None row = result.fetchone()
return row[0] if row else None
except Exception:
# Table doesn't exist yet (first run before any indexing)
return None
def date_to_epoch(date_str: str) -> float: def date_to_epoch(date_str: str) -> float: