diff --git a/yj_room_agent/LLM/ai_service.py b/yj_room_agent/LLM/ai_service.py index 1299236..744d16f 100644 --- a/yj_room_agent/LLM/ai_service.py +++ b/yj_room_agent/LLM/ai_service.py @@ -38,6 +38,7 @@ def is_json(myjson): json_object = json.loads(myjson) return True except ValueError: + print("json检查未通过") return False @@ -105,6 +106,7 @@ def query_room_info(data: dict, params: dict) -> str: if (region in b.get('name', 'default') or region in b.get('typeName', 'default')) and b.get('capacity',0) >= data.get('capacity', 0): new_list.append(b) if len(new_list) >= DEFAULT_QUERY_SIZE: + print("regin--------------- {0}".format(new_list)) return json.dumps(new_list, ensure_ascii=False) else: for b in result: @@ -112,6 +114,7 @@ def query_room_info(data: dict, params: dict) -> str: new_list.append(b) if len(new_list) >= DEFAULT_QUERY_SIZE: return json.dumps(new_list, ensure_ascii=False) + print("no regin-------------- {0}".format(new_list)) return json.dumps(new_list, ensure_ascii=False) @@ -303,7 +306,6 @@ def build_prompt(params): qry_room_info_for_mart_str = ''' { - "func_name":"query_room", "capacity":20, //参会人数,没有则返回0,, "Region":"成都", //会议室所在区域,没有则返回None @@ -324,8 +326,7 @@ def build_prompt(params): qry_book_info_for_mart_str = ''' { - - "func_name":"query_booking_info", + "func_name":"query_booking_info" } ''' @@ -367,8 +368,8 @@ def build_prompt(params): {book_for_mart_str} 3. 用户需要查询已有的会议室预订情况或者预订情况时,实时查询,禁止使用历史对话数据,结果请按照以下的json示例返回,不需要返回其他的多余数据,返回示例如下: {qry_book_info_for_mart_str} - 4. 如果用户需要取消预订会议时,请根据上下文提取用户取消信息,分两种情况: - (1)用户未提供要取消的会议号ID,返回已预定会议情况供用户选择,切记禁止使用历史对话中的旧数据!,查询调用如下: + 4. 如果用户需要取消预订会议时,分两种情况: + (1)用户未提供要取消的会议号ID,返回已预定会议情况供用户选择,实时查询,禁止使用历史对话中的旧数据!,查询调用如下: {qry_book_info_for_mart_str} 返回格式规范:{return_booking_info_str} (2)用户给出了需要取消的会议号ID,如果用户从已预定会议列表中选择了需要取消的会议,则提取会议ID,并提示用户是否确认取消,取消示例如下: {cancel_meeting_info_for_mart_str} @@ -616,7 +617,8 @@ def process_chat(user_id: str, user_input: str, params: dict): # 触发函数调用------ logger.info(f"触发系统函数调用==>:{fun_name}") book_promot = func(data=data, params=params) - dialog_manager.add_message(user_id, 'user', book_promot) + logger.info("test point book_promot => {0} ".format(book_promot)) + # dialog_manager.add_message(user_id, 'user', book_promot) else: book_promot = f''' @@ -631,6 +633,7 @@ def process_chat(user_id: str, user_input: str, params: dict): 请帮用户解析结果,并根据结果给予用户相应自然语言反馈 ''' new_history = [] + logger.info("test point completed the function call ") query_history = dialog_manager.get_history(user_id) new_history.extend(query_history) resp = call_openai_api(model=MODEL_NAME, user_query=book_promot, @@ -640,11 +643,12 @@ def process_chat(user_id: str, user_input: str, params: dict): temperature=config("MODEL_TEMPERATURE", cast=float, default=0.5), ) content = resp["choices"][0]["message"]["content"] + logger.info("final content => {0}".format(content)) new_content = check_and_process_think(content) add_message_async(dialog_manager, user_id, 'assistant', content) return {'response': new_content} else: - + logger.info("no func ") add_message_async(dialog_manager, user_id, 'assistant', content) if reasoning_content: add_message_async(dialog_manager, user_id, 'assistant', reasoning_content)