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>
This commit is contained in:
@@ -59,6 +59,7 @@ text_splitter = RecursiveCharacterTextSplitter(
|
||||
def _get_collection_id():
|
||||
"""Get the UUID of our collection from the langchain_pg_collection table."""
|
||||
engine = _get_engine()
|
||||
try:
|
||||
with engine.connect() as conn:
|
||||
result = conn.execute(
|
||||
text("SELECT uuid FROM langchain_pg_collection WHERE name = :name"),
|
||||
@@ -66,6 +67,9 @@ def _get_collection_id():
|
||||
)
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user