put try/except block

This commit is contained in:
Lanznx 2023-11-10 18:39:24 +08:00
commit 3e6e6b44b5

View file

@ -14,7 +14,9 @@ class PostgresqlVectorComponent(CustomComponent):
display_name: str = "PGVector" display_name: str = "PGVector"
description: str = "Implementation of Vector Store using PostgreSQL" description: str = "Implementation of Vector Store using PostgreSQL"
documentation = "https://python.langchain.com/docs/integrations/vectorstores/pgvector" documentation = (
"https://python.langchain.com/docs/integrations/vectorstores/pgvector"
)
beta = True beta = True
def build_config(self): def build_config(self):
@ -56,11 +58,12 @@ class PostgresqlVectorComponent(CustomComponent):
- VectorStore: The Vector Store object. - VectorStore: The Vector Store object.
""" """
return PGVector.from_documents( try:
embedding=embedding, return PGVector.from_documents(
documents=documents, embedding=embedding,
collection_name=collection_name, documents=documents,
connection_string=pg_server_url, collection_name=collection_name,
) connection_string=pg_server_url,
)
except Exception as e:
raise RuntimeError(f"Failed to build Vector Store: {str(e)}")