@@ -71,28 +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- if len (
75- self .function_store .get_all (
76- group_identifier = str (request .project_id )
77- )
78- ) <= 0 and (len (request .functions ) <= 0 ):
79- log .warning (f"[Prompt] Rejected — no functions for project={ request .project_id } " )
80- context .abort (
81- code = grpc .StatusCode .ABORTED ,
82- details = "No functions found for the given project_id. Please add functions before requesting a prompt generation."
83- )
84-
85- if len (
86- self .flow_type_store .get_all (
87- group_identifier = str (request .project_id )
88- )
89- ) <= 0 and (len (request .flow_types ) <= 0 ):
90- log .warning (f"[Prompt] Rejected — no flow types for project={ request .project_id } " )
91- context .abort (
92- code = grpc .StatusCode .ABORTED ,
93- details = "No flow types found for the given project_id. Please add flow_types before requesting a prompt generation."
94- )
95-
9674 functions = [
9775 map_to_function_schema (fn )
9876 for fn in request .functions
@@ -122,6 +100,30 @@ def Prompt(self, request: pb2.PromptRequest, context) -> pb2.FlowResponse:
122100 data_types = data_types
123101 )
124102
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+
125127 prompt_functions = self .function_store .search (
126128 group_identifier = str (request .project_id ),
127129 prompt = request .prompt ,
@@ -272,28 +274,6 @@ def Flow(self, request: pb2.FlowRequest, context) -> pb2.FlowResponse:
272274 details = f"The specified model_identifier '{ request .model_identifier } ' does not exist. Please provide a valid model_identifier for flow generation."
273275 )
274276
275- if len (
276- self .function_store .get_all (
277- group_identifier = str (request .project_id )
278- )
279- ) <= 0 and (len (request .functions ) <= 0 ):
280- log .warning (f"[Flow] Rejected — no functions for project={ request .project_id } " )
281- context .abort (
282- code = grpc .StatusCode .ABORTED ,
283- details = "No functions found for the given project_id. Please add functions before requesting a prompt generation."
284- )
285-
286- if len (
287- self .flow_type_store .get_all (
288- group_identifier = str (request .project_id )
289- )
290- ) <= 0 and (len (request .flow_types ) <= 0 ):
291- log .warning (f"[Flow] Rejected — no flow types for project={ request .project_id } " )
292- context .abort (
293- code = grpc .StatusCode .ABORTED ,
294- details = "No flow types found for the given project_id. Please add flow_types before requesting a prompt generation."
295- )
296-
297277 functions = [
298278 map_to_function_schema (fn )
299279 for fn in request .functions
@@ -323,6 +303,30 @@ def Flow(self, request: pb2.FlowRequest, context) -> pb2.FlowResponse:
323303 data_types = data_types
324304 )
325305
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+
326330 prompt_functions = self .function_store .search (
327331 group_identifier = str (request .project_id ),
328332 prompt = request .prompt ,
0 commit comments