langchain-postgres icon indicating copy to clipboard operation
langchain-postgres copied to clipboard

Error while upgrading psycopg2 to psycopg with "from langchain_postgres import PGVector" and "langchain_postgres.vectorstores import PGVector"

Open rkrkrediffmail opened this issue 1 year ago • 2 comments

Checked other resources

  • [X] I added a very descriptive title to this issue.
  • [X] I searched the LangChain documentation with the integrated search.
  • [X] I used the GitHub search to find a similar question and didn't find it.
  • [X] I am sure that this is a bug in LangChain rather than my code.
  • [X] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

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

rkrkrediffmail avatar May 02 '24 12:05 rkrkrediffmail

any idea on this

tejeshbhalla avatar May 09 '24 15:05 tejeshbhalla

??

tejeshbhalla avatar May 09 '24 15:05 tejeshbhalla

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.

evahbe avatar May 15 '24 08:05 evahbe

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

eyurtsev avatar May 17 '24 15:05 eyurtsev