@@ -13,13 +13,13 @@ def __init__(self, config: Optional[BaseEmbedderConfig] = None):
13
13
14
14
self .config .model = self .config .model or "text-embedding-004"
15
15
self .config .embedding_dims = self .config .embedding_dims or 256
16
-
16
+
17
17
self .embedding_types = {
18
18
"add" : self .config .memory_add_embedding_type or "RETRIEVAL_DOCUMENT" ,
19
19
"update" : self .config .memory_update_embedding_type or "RETRIEVAL_DOCUMENT" ,
20
- "search" : self .config .memory_search_embedding_type or "RETRIEVAL_QUERY"
20
+ "search" : self .config .memory_search_embedding_type or "RETRIEVAL_QUERY" ,
21
21
}
22
-
22
+
23
23
credentials_path = self .config .vertex_credentials_json
24
24
25
25
if credentials_path :
@@ -31,7 +31,7 @@ def __init__(self, config: Optional[BaseEmbedderConfig] = None):
31
31
32
32
self .model = TextEmbeddingModel .from_pretrained (self .config .model )
33
33
34
- def embed (self , text , memory_action :Optional [Literal ["add" , "search" , "update" ]] = None ):
34
+ def embed (self , text , memory_action : Optional [Literal ["add" , "search" , "update" ]] = None ):
35
35
"""
36
36
Get the embedding for the given text using Vertex AI.
37
37
@@ -45,9 +45,9 @@ def embed(self, text, memory_action:Optional[Literal["add", "search", "update"]]
45
45
if memory_action is not None :
46
46
if memory_action not in self .embedding_types :
47
47
raise ValueError (f"Invalid memory action: { memory_action } " )
48
-
48
+
49
49
embedding_type = self .embedding_types [memory_action ]
50
-
50
+
51
51
text_input = TextEmbeddingInput (text = text , task_type = embedding_type )
52
52
embeddings = self .model .get_embeddings (texts = [text_input ], output_dimensionality = self .config .embedding_dims )
53
53
0 commit comments