mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
Error while upgrading psycopg2 to psycopg with "from langchain_postgres import PGVector" and "langchain_postgres.vectorstores import PGVector" #11
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 @rkrkrediffmail on GitHub (May 2, 2024).
Checked other resources
Example Code
#!/usr/bin/python3
import os
import psycopg
from psycopg import sql
from langchain_postgres import PGVector
from langchain_postgres.vectorstores import PGVector
#from langchain.vectorstores.pgvector import PGVector
#from langchain.vectorstores.pgvector import DistanceStrategy
from langchain_openai import AzureOpenAIEmbeddings
from langchain_openai import AzureChatOpenAI
Error Message and Stack Trace (if applicable)
Exception ignored in: <function PGVector.del at 0x7fa9436f2a70>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/langchain_postgres/vectorstores.py", line 326, in del
if isinstance(self._engine, sqlalchemy.engine.Connection):
AttributeError: 'PGVector' object has no attribute '_engine'
this is the error: PGVector.init() got an unexpected keyword argument 'connection_string'
Description
I have a RAG bot on AzureOpenAI. It has been working fine. However, after i upgraded my python=3.10 and openai>1.0, i upgraded the langchain modules as well. i had replaced the pgvector to "from langchain_postgres import PGVector"
With the above upgrades and i tried creating new embeddings with "text-embedding-3-large" i get the following error.
Exception ignored in: <function PGVector.del at 0x7fa9436f2a70>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/langchain_postgres/vectorstores.py", line 326, in del
if isinstance(self._engine, sqlalchemy.engine.Connection):
AttributeError: 'PGVector' object has no attribute '_engine'
this is the error: PGVector.init() got an unexpected keyword argument 'connection_string'
i entirely removed the langchain_pg_collection and langchain_pg_embedding as the vector size was different (1536 to 3072)
System Info
langchain==0.1.16
langchain-community==0.0.34
langchain-core==0.1.46
langchain-mistralai==0.0.4
langchain-openai==0.1.3
langchain-postgres==0.0.3
langchain-text-splitters==0.0.1
pgvector==0.2.5
psycopg==3.1.18
psycopg-binary==3.1.18
psycopg-pool==3.2.1
@tejeshbhalla commented on GitHub (May 9, 2024):
any idea on this
@tejeshbhalla commented on GitHub (May 9, 2024):
??
@evahbe commented on GitHub (May 15, 2024):
Hello @rkrkrediffmail could you share your connection string? I was playing with the "+psycopg" part of my connection string and after removing it, everything worked fine.
@eyurtsev commented on GitHub (May 17, 2024):
this is the error: PGVector.init() got an unexpected keyword argument 'connection_string'Use connection not connection_string
https://github.com/langchain-ai/langchain-postgres/blob/main/examples/vectorstore.ipynb