1- from typing import Any , Dict
1+ from typing import Any , Dict , List , Optional
22from controller .auth import manager as auth
33from controller .embedding import manager
44from controller .auth .manager import get_user_by_info
@@ -31,6 +31,8 @@ def mutate(self, info, project_id: str, attribute_id: str, config: Dict[str, Any
3131 api_token = config .get ("apiToken" )
3232 terms_text = config .get ("termsText" )
3333 terms_accepted = config .get ("termsAccepted" )
34+ filter_attributes = config .get ("filterAttributes" )
35+
3436 additional_data = None
3537 if config .get ("base" ) is not None :
3638 additional_data = {
@@ -39,10 +41,6 @@ def mutate(self, info, project_id: str, attribute_id: str, config: Dict[str, Any
3941 "version" : config .get ("version" ),
4042 }
4143
42- # prototyping logic, this will be part of config after ui integration
43- relevant_attribute_list = attribute_do .get_all_possible_names_for_qdrant (
44- project_id
45- )
4644 task_queue_manager .add_task (
4745 project_id ,
4846 TaskType .EMBEDDING ,
@@ -58,7 +56,7 @@ def mutate(self, info, project_id: str, attribute_id: str, config: Dict[str, Any
5856 "api_token" : api_token ,
5957 "terms_text" : terms_text ,
6058 "terms_accepted" : terms_accepted ,
61- "filter_attributes" : relevant_attribute_list ,
59+ "filter_attributes" : filter_attributes ,
6260 "additional_data" : additional_data ,
6361 },
6462 )
@@ -85,6 +83,31 @@ def mutate(self, info, project_id: str, embedding_id: str):
8583 return DeleteEmbedding (ok = True )
8684
8785
86+ class UpdateEmbeddingPayload (graphene .Mutation ):
87+ class Arguments :
88+ project_id = graphene .ID (required = True )
89+ embedding_id = graphene .ID (required = True )
90+ filter_attributes = graphene .JSONString (required = False )
91+
92+ ok = graphene .Boolean ()
93+
94+ def mutate (
95+ self ,
96+ info ,
97+ project_id : str ,
98+ embedding_id : str ,
99+ filter_attributes : Optional [List [str ]] = None ,
100+ ):
101+ auth .check_demo_access (info )
102+ auth .check_project_access (info , project_id )
103+ manager .update_embedding_payload (project_id , embedding_id , filter_attributes )
104+ notification .send_organization_update (
105+ project_id , f"embedding_updated:{ embedding_id } "
106+ )
107+ return UpdateEmbeddingPayload (ok = True )
108+
109+
88110class EmbeddingMutation (graphene .ObjectType ):
89111 create_embedding = CreateEmbedding .Field ()
90112 delete_embedding = DeleteEmbedding .Field ()
113+ update_embedding_payload = UpdateEmbeddingPayload .Field ()
0 commit comments