@@ -71,30 +71,6 @@ def Prompt(self, request: pb2.PromptRequest, context) -> pb2.FlowResponse:
7171 details = f"The specified model_identifier '{ request .model_identifier } ' does not exist. Please provide a valid model_identifier for flow generation."
7272 )
7373
74- stored_functions_count = len (self .function_store .get_all (group_identifier = str (request .project_id )))
75- stored_flow_types_count = len (self .flow_type_store .get_all (group_identifier = str (request .project_id )))
76- stored_few_shots_count = len (self .few_shots_store .get_all (group_identifier = "global" ))
77- log .info (
78- f"[Prompt] Store state — project={ request .project_id } "
79- f"functions={ stored_functions_count } "
80- f"flow_types={ stored_flow_types_count } "
81- f"few_shots={ stored_few_shots_count } "
82- )
83-
84- if stored_functions_count <= 0 and (len (request .functions ) <= 0 ):
85- log .warning (f"[Prompt] Rejected — no functions for project={ request .project_id } " )
86- context .abort (
87- code = grpc .StatusCode .ABORTED ,
88- details = "No functions found for the given project_id. Please add functions before requesting a prompt generation."
89- )
90-
91- if stored_flow_types_count <= 0 and (len (request .flow_types ) <= 0 ):
92- log .warning (f"[Prompt] Rejected — no flow types for project={ request .project_id } " )
93- context .abort (
94- code = grpc .StatusCode .ABORTED ,
95- details = "No flow types found for the given project_id. Please add flow_types before requesting a prompt generation."
96- )
97-
9874 functions = [
9975 map_to_function_schema (fn )
10076 for fn in request .functions
@@ -124,6 +100,30 @@ def Prompt(self, request: pb2.PromptRequest, context) -> pb2.FlowResponse:
124100 data_types = data_types
125101 )
126102
103+ stored_functions_count = len (self .function_store .get_all (group_identifier = str (request .project_id )))
104+ stored_flow_types_count = len (self .flow_type_store .get_all (group_identifier = str (request .project_id )))
105+ stored_few_shots_count = len (self .few_shots_store .get_all (group_identifier = "global" ))
106+ log .info (
107+ f"[Prompt] Store state — project={ request .project_id } "
108+ f"functions={ stored_functions_count } "
109+ f"flow_types={ stored_flow_types_count } "
110+ f"few_shots={ stored_few_shots_count } "
111+ )
112+
113+ if stored_functions_count <= 0 :
114+ log .warning (f"[Prompt] Rejected — no functions for project={ request .project_id } " )
115+ context .abort (
116+ code = grpc .StatusCode .ABORTED ,
117+ details = "No functions found for the given project_id. Please add functions before requesting a prompt generation."
118+ )
119+
120+ if stored_flow_types_count <= 0 :
121+ log .warning (f"[Prompt] Rejected — no flow types for project={ request .project_id } " )
122+ context .abort (
123+ code = grpc .StatusCode .ABORTED ,
124+ details = "No flow types found for the given project_id. Please add flow_types before requesting a prompt generation."
125+ )
126+
127127 prompt_functions = self .function_store .search (
128128 group_identifier = str (request .project_id ),
129129 prompt = request .prompt ,
@@ -274,30 +274,6 @@ def Flow(self, request: pb2.FlowRequest, context) -> pb2.FlowResponse:
274274 details = f"The specified model_identifier '{ request .model_identifier } ' does not exist. Please provide a valid model_identifier for flow generation."
275275 )
276276
277- stored_functions_count = len (self .function_store .get_all (group_identifier = str (request .project_id )))
278- stored_flow_types_count = len (self .flow_type_store .get_all (group_identifier = str (request .project_id )))
279- stored_few_shots_count = len (self .few_shots_store .get_all (group_identifier = "global" ))
280- log .info (
281- f"[Flow] Store state — project={ request .project_id } "
282- f"functions={ stored_functions_count } "
283- f"flow_types={ stored_flow_types_count } "
284- f"few_shots={ stored_few_shots_count } "
285- )
286-
287- if stored_functions_count <= 0 and (len (request .functions ) <= 0 ):
288- log .warning (f"[Flow] Rejected — no functions for project={ request .project_id } " )
289- context .abort (
290- code = grpc .StatusCode .ABORTED ,
291- details = "No functions found for the given project_id. Please add functions before requesting a prompt generation."
292- )
293-
294- if stored_flow_types_count <= 0 and (len (request .flow_types ) <= 0 ):
295- log .warning (f"[Flow] Rejected — no flow types for project={ request .project_id } " )
296- context .abort (
297- code = grpc .StatusCode .ABORTED ,
298- details = "No flow types found for the given project_id. Please add flow_types before requesting a prompt generation."
299- )
300-
301277 functions = [
302278 map_to_function_schema (fn )
303279 for fn in request .functions
@@ -327,6 +303,30 @@ def Flow(self, request: pb2.FlowRequest, context) -> pb2.FlowResponse:
327303 data_types = data_types
328304 )
329305
306+ stored_functions_count = len (self .function_store .get_all (group_identifier = str (request .project_id )))
307+ stored_flow_types_count = len (self .flow_type_store .get_all (group_identifier = str (request .project_id )))
308+ stored_few_shots_count = len (self .few_shots_store .get_all (group_identifier = "global" ))
309+ log .info (
310+ f"[Flow] Store state — project={ request .project_id } "
311+ f"functions={ stored_functions_count } "
312+ f"flow_types={ stored_flow_types_count } "
313+ f"few_shots={ stored_few_shots_count } "
314+ )
315+
316+ if stored_functions_count <= 0 :
317+ log .warning (f"[Flow] Rejected — no functions for project={ request .project_id } " )
318+ context .abort (
319+ code = grpc .StatusCode .ABORTED ,
320+ details = "No functions found for the given project_id. Please add functions before requesting a prompt generation."
321+ )
322+
323+ if stored_flow_types_count <= 0 :
324+ log .warning (f"[Flow] Rejected — no flow types for project={ request .project_id } " )
325+ context .abort (
326+ code = grpc .StatusCode .ABORTED ,
327+ details = "No flow types found for the given project_id. Please add flow_types before requesting a prompt generation."
328+ )
329+
330330 prompt_functions = self .function_store .search (
331331 group_identifier = str (request .project_id ),
332332 prompt = request .prompt ,
0 commit comments