The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
[Bugfix] fix google ai embedding function (#1195)
Deven Patel0b5b12575af7
diff --git a/embedchain/embedder/google.py b/embedchain/embedder/google.pyindex 4d09f6be6..c0be83500 100644--- a/embedchain/embedder/google.py+++ b/embedchain/embedder/google.py@@ -1,4 +1,4 @@-from typing import Optional+from typing import Optional, Unionimport google.generativeai as genaifrom chromadb import EmbeddingFunction, Embeddings@@ -13,12 +13,19 @@ class GoogleAIEmbeddingFunction(EmbeddingFunction):super().__init__()self.config = config or GoogleAIEmbedderConfig()- def __call__(self, input_: str) -> Embeddings:+ def __call__(self, input: Union[list[str], str]) -> Embeddings:model = self.config.modeltitle = self.config.titletask_type = self.config.task_type- embeddings = genai.embed_content(model=model, content=input_, task_type=task_type, title=title)- return embeddings["embedding"]+ if isinstance(input, str):+ input_ = [input]+ else:+ input_ = input+ data = genai.embed_content(model=model, content=input_, task_type=task_type, title=title)+ embeddings = data["embedding"]+ if isinstance(input_, str):+ embeddings = [embeddings]+ return embeddingsclass GoogleAIEmbedder(BaseEmbedder):