Update max_token and formatting (#2273)

This commit is contained in:
Dev Khant
2025-02-28 15:59:34 +05:30
committed by GitHub
parent 6acb00731d
commit b131c4bfc4
25 changed files with 31 additions and 32 deletions

View File

@@ -13,13 +13,13 @@ class VertexAIEmbedding(EmbeddingBase):
self.config.model = self.config.model or "text-embedding-004"
self.config.embedding_dims = self.config.embedding_dims or 256
self.embedding_types = {
"add": self.config.memory_add_embedding_type or "RETRIEVAL_DOCUMENT",
"update": self.config.memory_update_embedding_type or "RETRIEVAL_DOCUMENT",
"search": self.config.memory_search_embedding_type or "RETRIEVAL_QUERY"
"search": self.config.memory_search_embedding_type or "RETRIEVAL_QUERY",
}
credentials_path = self.config.vertex_credentials_json
if credentials_path:
@@ -31,7 +31,7 @@ class VertexAIEmbedding(EmbeddingBase):
self.model = TextEmbeddingModel.from_pretrained(self.config.model)
def embed(self, text, memory_action:Optional[Literal["add", "search", "update"]] = None):
def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None):
"""
Get the embedding for the given text using Vertex AI.
@@ -45,9 +45,9 @@ class VertexAIEmbedding(EmbeddingBase):
if memory_action is not None:
if memory_action not in self.embedding_types:
raise ValueError(f"Invalid memory action: {memory_action}")
embedding_type = self.embedding_types[memory_action]
text_input = TextEmbeddingInput(text=text, task_type=embedding_type)
embeddings = self.model.get_embeddings(texts=[text_input], output_dimensionality=self.config.embedding_dims)