MCPcopy Create free account
hub / github.com/answerlink/IntelliQ / recognize_intent

Method recognize_intent

models/chatbot_model.py:38–64  ·  view source on GitHub ↗
(self, user_input)

Source from the content-addressed store, hash-verified

36 return result == '是'
37
38 def recognize_intent(self, user_input):
39 # 根据场景模板生成选项
40 purpose_options = {}
41 purpose_description = {}
42 index = 1
43 for template_key, template_info in self.scene_templates.items():
44 purpose_options[str(index)] = template_key
45 purpose_description[str(index)] = template_info["description"]
46 index += 1
47 options_prompt = "\n".join([f"{key}. {value} - 请回复{key}" for key, value in purpose_description.items()])
48 options_prompt += "\n0. 其他场景 - 请回复0"
49
50 # 发送选项给用户
51 user_choice = send_message(f"有下面多种场景,需要你根据用户输入进行判断,只答选项\n{options_prompt}\n用户输入:{user_input}\n请回复序号:", user_input)
52
53 print('purpose_options', purpose_options)
54 print('user_choice', user_choice)
55 # 根据用户选择获取对应场景
56 if user_choice != '0':
57 self.current_purpose = purpose_options[user_choice]
58
59 if self.current_purpose:
60 print(f"用户选择了场景:{self.scene_templates[self.current_purpose]['name']}")
61 # 这里可以继续处理其他逻辑
62 else:
63 # 用户输入的选项无效的情况,可以进行相应的处理
64 print("无效的选项,请重新选择")
65
66 def get_processor_for_scene(self, scene_name):
67 if scene_name in self.processors:

Callers 1

Calls 1

send_messageFunction · 0.90

Tested by

no test coverage detected