mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
Connection error use azure embedding #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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'
@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!