Open ausarhuy opened 3 months ago
from typing import List, Optional
from langchain_google_genai import GoogleGenerativeAIEmbeddings
class GeminiEmbeddings(GoogleGenerativeAIEmbeddings):
def embed_documents(self, texts: List[str],
task_type: Optional[str] = None,
titles: Optional[List[str]] = None,
output_dimensionality: Optional[int] = None) -> List[List[float]]:
embeddings = super().embed_documents(texts, task_type, titles, output_dimensionality)
# Convert Repeated type to list type
return list(map(list, embeddings))
This is my current quick fix.
class GeminiEmbeddings(GoogleGenerativeAIEmbeddings): def embed_documents(self, texts: List[str], task_type: Optional[str] = None, titles: Optional[List[str]] = None, output_dimensionality: Optional[int] = None) -> List[List[float]]: embeddings = super().embed_documents(texts, task_type, titles, output_dimensionality) # Convert Repeated type to list type return list(map(list, embeddings))
It throws TypeError: GoogleGenerativeAIEmbeddings.embed_documents() takes 2 positional arguments but 5 were given
.
I am using it with:
...
self.embeddings = GeminiEmbeddings(
model="models/embedding-001")
docsearch = Chroma.from_texts(..., embedding=self.embeddings, ...)
...
EDIT: using only super().embed_documents(texts)
works.
This returned type "Repeated" also breaks the CacheBackedEmbeddings when wrapping GoogleGenerativeAIEmbeddings.
This returned type "Repeated" also breaks the CacheBackedEmbeddings when wrapping GoogleGenerativeAIEmbeddings.
Yes, they either change Repeatd to List or add Repeated to all the vectorstores.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
No response
Description
It returns <class 'proto.marshal.collections.repeated.Repeated'> type not List type. It might work the same as a List type but not when using it in any vectorstore.
System Info
System Information
Package Information