Connection error use azure embedding #15

Open
opened 2026-02-16 05:16:04 -05:00 by yindo · 1 comment
Owner

Originally created by @cxy-gpt on GitHub (May 13, 2024).

code

`connection = "postgresql+psycopg://YYY:XXXX@localhost/ZZZ"
collection_name = "my_docs"
from langchain_postgres import PGVector
from langchain_postgres.vectorstores import PGVector

vectorstore = PGVector(
embeddings=embeddings,
collection_name=collection_name,
connection=connection,
use_jsonb=True,
)
db = vectorstore.from_texts( ["communication"], embeddings)`

error info
db = vectorstore.from_texts( ["communication"], embeddings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 975, in from_texts
return cls.__from(
^^^^^^^^^^^
File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 438, in __from
store = cls(
^^^^
File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 295, in init
raise ValueError(
ValueError: connection should be a connection string or an instance of sqlalchemy.engine.Engine
Exception ignored in: <function PGVector.del at 0x7fdf7b19dda0>
Traceback (most recent call last):
File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 326, in del
if isinstance(self._engine, sqlalchemy.engine.Connection):
^^^^^^^^^^^^
AttributeError: 'PGVector' object has no attribute '_engine'

Originally created by @cxy-gpt on GitHub (May 13, 2024). ### code `connection = "postgresql+psycopg://YYY:XXXX@localhost/ZZZ" collection_name = "my_docs" from langchain_postgres import PGVector from langchain_postgres.vectorstores import PGVector vectorstore = PGVector( embeddings=embeddings, collection_name=collection_name, connection=connection, use_jsonb=True, ) db = vectorstore.from_texts( ["communication"], embeddings)` **error info** db = vectorstore.from_texts( ["communication"], embeddings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 975, in from_texts return cls.__from( ^^^^^^^^^^^ File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 438, in __from store = cls( ^^^^ File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 295, in __init__ raise ValueError( ValueError: connection should be a connection string or an instance of sqlalchemy.engine.Engine Exception ignored in: <function PGVector.__del__ at 0x7fdf7b19dda0> Traceback (most recent call last): File "/usr/local/anaconda3/lib/python3.11/site-packages/langchain_postgres/vectorstores.py", line 326, in __del__ if isinstance(self._engine, sqlalchemy.engine.Connection): ^^^^^^^^^^^^ AttributeError: 'PGVector' object has no attribute '_engine'
Author
Owner

@evahbe commented on GitHub (May 14, 2024):

I think it is because it is not detecting correctly the 'connection_string' parameter, try checking and varying it, mostly adding/removing the "+psycopg" part, for me it kinda worked. Got some other error after, but at least not that one any more!

@evahbe commented on GitHub (May 14, 2024): I think it is because it is not detecting correctly the 'connection_string' parameter, try checking and varying it, mostly adding/removing the "+psycopg" part, for me it kinda worked. Got some other error after, but at least not that one any more!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#15