object has no attribute "embed_documents" #21

Closed
opened 2026-02-16 05:16:07 -05:00 by yindo · 1 comment
Owner

Originally created by @sashokbg on GitHub (Jun 6, 2024).

Hello I am trying to run a simple example with langchain and I get:

/home/alexander/projects/cycleup-assistant-venv/bin/python3.12 -X pycache_prefix=/home/alexander/.cache/JetBrains/IntelliJIdea2023.3/cpython-cache /home/alexander/.local/share/JetBrains/IntelliJIdea2023.3/python/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 37191 --file /home/alexander/projects/cycleup-assistant/flows/embeddings/functions/embeddings.py 
Connected to pydev debugger (build 233.14475.28)
Traceback (most recent call last):
  File "/home/alexander/.local/share/JetBrains/IntelliJIdea2023.3/python/helpers/pydev/pydevd.py", line 1534, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alexander/.local/share/JetBrains/IntelliJIdea2023.3/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/alexander/projects/cycleup-assistant/flows/embeddings/functions/embeddings.py", line 61, in <module>
    embeddings()
  File "/home/alexander/projects/cycleup-assistant/flows/embeddings/functions/embeddings.py", line 50, in embeddings
    vectorstore = PGVector.from_documents(
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alexander/projects/cycleup-assistant-venv/lib/python3.12/site-packages/langchain_postgres/vectorstores.py", line 1119, in from_documents
    return cls.from_texts(
           ^^^^^^^^^^^^^^^
  File "/home/alexander/projects/cycleup-assistant-venv/lib/python3.12/site-packages/langchain_postgres/vectorstores.py", line 985, in from_texts
    embeddings = embedding.embed_documents(list(texts))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'embed_documents'
python-BaseException

I am using OpenAiEmbeddings

Everything is latest verssion.

Is there some interface change on the OpenAI end that might be the cause of the break ?

Originally created by @sashokbg on GitHub (Jun 6, 2024). Hello I am trying to run a simple example with langchain and I get: ``` /home/alexander/projects/cycleup-assistant-venv/bin/python3.12 -X pycache_prefix=/home/alexander/.cache/JetBrains/IntelliJIdea2023.3/cpython-cache /home/alexander/.local/share/JetBrains/IntelliJIdea2023.3/python/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 37191 --file /home/alexander/projects/cycleup-assistant/flows/embeddings/functions/embeddings.py Connected to pydev debugger (build 233.14475.28) Traceback (most recent call last): File "/home/alexander/.local/share/JetBrains/IntelliJIdea2023.3/python/helpers/pydev/pydevd.py", line 1534, in _exec pydev_imports.execfile(file, globals, locals) # execute the script ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/alexander/.local/share/JetBrains/IntelliJIdea2023.3/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/alexander/projects/cycleup-assistant/flows/embeddings/functions/embeddings.py", line 61, in <module> embeddings() File "/home/alexander/projects/cycleup-assistant/flows/embeddings/functions/embeddings.py", line 50, in embeddings vectorstore = PGVector.from_documents( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/alexander/projects/cycleup-assistant-venv/lib/python3.12/site-packages/langchain_postgres/vectorstores.py", line 1119, in from_documents return cls.from_texts( ^^^^^^^^^^^^^^^ File "/home/alexander/projects/cycleup-assistant-venv/lib/python3.12/site-packages/langchain_postgres/vectorstores.py", line 985, in from_texts embeddings = embedding.embed_documents(list(texts)) ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'function' object has no attribute 'embed_documents' python-BaseException ``` I am using OpenAiEmbeddings Everything is latest verssion. Is there some interface change on the OpenAI end that might be the cause of the break ?
yindo closed this issue 2026-02-16 05:16:07 -05:00
Author
Owner

@sashokbg commented on GitHub (Jun 6, 2024):

Ah silly me .. I was redefining the method "embeddings" in my python file.

Closing

@sashokbg commented on GitHub (Jun 6, 2024): Ah silly me .. I was redefining the method "embeddings" in my python file. Closing
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#21