@@ -268,24 +268,37 @@ def get_fields_from_chart(self, _session: Session):
268268 return format_chart_fields (chart_info )
269269
270270 def filter_terminology_template (self , _session : Session , oid : int = None , ds_id : int = None ):
271+ calculate_oid = oid
272+ calculate_ds_id = ds_id
273+ if self .current_assistant :
274+ calculate_oid = self .current_assistant .oid if self .current_assistant .type != 4 else self .current_user .oid
275+ if self .current_assistant .type == 1 :
276+ calculate_ds_id = None
271277 self .current_logs [OperationEnum .FILTER_TERMS ] = start_log (session = _session ,
272278 operate = OperationEnum .FILTER_TERMS ,
273279 record_id = self .record .id , local_operation = True )
280+
274281 self .chat_question .terminologies , term_list = get_terminology_template (_session , self .chat_question .question ,
275- oid , ds_id )
282+ calculate_oid , calculate_ds_id )
276283 self .current_logs [OperationEnum .FILTER_TERMS ] = end_log (session = _session ,
277284 log = self .current_logs [OperationEnum .FILTER_TERMS ],
278285 full_message = term_list )
279286
280287 def filter_custom_prompts (self , _session : Session , custom_prompt_type : CustomPromptTypeEnum , oid : int = None ,
281288 ds_id : int = None ):
282289 if SQLBotLicenseUtil .valid ():
290+ calculate_oid = oid
291+ calculate_ds_id = ds_id
292+ if self .current_assistant :
293+ calculate_oid = self .current_assistant .oid if self .current_assistant .type != 4 else self .current_user .oid
294+ if self .current_assistant .type == 1 :
295+ calculate_ds_id = None
283296 self .current_logs [OperationEnum .FILTER_CUSTOM_PROMPT ] = start_log (session = _session ,
284297 operate = OperationEnum .FILTER_CUSTOM_PROMPT ,
285298 record_id = self .record .id ,
286299 local_operation = True )
287- self .chat_question .custom_prompt , prompt_list = find_custom_prompts (_session , custom_prompt_type , oid ,
288- ds_id )
300+ self .chat_question .custom_prompt , prompt_list = find_custom_prompts (_session , custom_prompt_type , calculate_oid ,
301+ calculate_ds_id )
289302 self .current_logs [OperationEnum .FILTER_CUSTOM_PROMPT ] = end_log (session = _session ,
290303 log = self .current_logs [
291304 OperationEnum .FILTER_CUSTOM_PROMPT ],
@@ -296,14 +309,20 @@ def filter_training_template(self, _session: Session, oid: int = None, ds_id: in
296309 operate = OperationEnum .FILTER_SQL_EXAMPLE ,
297310 record_id = self .record .id ,
298311 local_operation = True )
312+ calculate_oid = oid
313+ calculate_ds_id = ds_id
314+ if self .current_assistant :
315+ calculate_oid = self .current_assistant .oid if self .current_assistant .type != 4 else self .current_user .oid
316+ if self .current_assistant .type == 1 :
317+ calculate_ds_id = None
299318 if self .current_assistant and self .current_assistant .type == 1 :
300319 self .chat_question .data_training , example_list = get_training_template (_session ,
301- self .chat_question .question , oid ,
320+ self .chat_question .question , calculate_oid ,
302321 None , self .current_assistant .id )
303322 else :
304323 self .chat_question .data_training , example_list = get_training_template (_session ,
305- self .chat_question .question , oid ,
306- ds_id )
324+ self .chat_question .question , calculate_oid ,
325+ calculate_ds_id )
307326 self .current_logs [OperationEnum .FILTER_SQL_EXAMPLE ] = end_log (session = _session ,
308327 log = self .current_logs [
309328 OperationEnum .FILTER_SQL_EXAMPLE ],
0 commit comments