langchain GoogleGenerativeAIEmbeddings的embed_documents方法返回了Repeated类型的列表,

iqjalb3h  于 24天前  发布在  Go
关注(0)|答案(4)|浏览(19)

检查其他资源

  • 为这个问题添加了一个非常描述性的标题。
  • 使用集成搜索在LangChain文档中进行了搜索。
  • 使用GitHub搜索查找类似的问题,但没有找到。
  • 我确信这是LangChain中的一个bug,而不是我的代码。
  • 通过更新到LangChain的最新稳定版本(或特定集成包)无法解决这个bug。

示例代码

from langchain_google_genai import GoogleGenerativeAIEmbeddings

embeddings = GoogleGenerativeAIEmbeddings(model='models/embedding-001')
vectors = embeddings.embed_documents(queries)

print(type(vectors[0]))

错误信息和堆栈跟踪(如果适用)

  • 无响应*

描述

它返回<class 'proto.marshal.collections.repeated.Repeated'>类型,而不是List类型。它可能与List类型一样工作,但在使用任何向量存储时不起作用。

系统信息

系统信息

操作系统:Linux
操作系统版本:#1 SMP Thu Jan 11 04:09:03 UTC 2024
Python版本:3.10.14(主版本,5月6日2024年,19:42:50) [GCC 11.2.0]

软件包信息

langchain_core: 0.2.3
langchain: 0.2.1
langchain_community: 0.2.1
langsmith: 0.1.67
langchain_google_genai: 1.0.5
langchain_text_splitters: 0.2.0
langgraph: 0.0.60

t1rydlwq

t1rydlwq1#

这是我目前的快速解决方案。

sz81bmfz

sz81bmfz2#

它抛出 TypeError: GoogleGenerativeAIEmbeddings.embed_documents() takes 2 positional arguments but 5 were given
我正在使用它:

...
self.embeddings = GeminiEmbeddings(
            model="models/embedding-001")
 docsearch = Chroma.from_texts(..., embedding=self.embeddings, ...) 
...

编辑:仅使用 super().embed_documents(texts) 就可以工作。

taor4pac

taor4pac3#

这个返回类型"Repeated"也破坏了CacheBackedEmbeddings,当 Package GoogleGenerativeAIEmbeddings时。

imzjd6km

imzjd6km4#

这个返回类型"Repeated"也会破坏CacheBackedEmbeddings,当 Package GoogleGenerativeAIEmbeddings时。
是的,他们要么将Repeatd更改为List,要么在所有向量存储中添加Repeated。

相关问题