更新意图识别模块,优化软件锁类的描述信息,增强代码可读性。同时,调整分类信息示例,新增后缀名咨询的示例,提升用户体验。更新多个二进制索引文件以反映最新变化。
This commit is contained in:
@@ -239,8 +239,8 @@ class FileExtensionConsultingSlots(SlotBase):
|
||||
|
||||
# 3.2 软件锁类
|
||||
class SoftwareLockSlots(SlotBase):
|
||||
lock_type: str = Field(default="", description="锁类型")
|
||||
operation_purpose: str = Field(default="", description="操作目的")
|
||||
lock_type: str = Field(default="", description="锁类型(单机锁、网络锁)")
|
||||
operation_purpose: str = Field(default="", description="操作目的(查询锁信息、无法激活、无法注册)")
|
||||
lock_number: Optional[str] = Field(default="", description="软件锁编号/注册号")
|
||||
|
||||
def check_required_slots(self) -> Tuple[bool, Dict[str, str]]:
|
||||
|
||||
@@ -52,6 +52,7 @@ class IntentRecognizer:
|
||||
# 初始化LLM
|
||||
llm_params = {
|
||||
"temperature": 0.2, # 降低随机性,使结果更确定
|
||||
"top_p": 0.7,
|
||||
"model": model_name
|
||||
}
|
||||
|
||||
@@ -117,14 +118,15 @@ class IntentRecognizer:
|
||||
output_format=classification_parser.get_format_instructions(),
|
||||
conversation_context=conversation_context,
|
||||
chat_history=json.dumps(chat_history, ensure_ascii=False))
|
||||
|
||||
# 调用LLM
|
||||
response = self._llm.invoke(formatted_prompt, False)
|
||||
classification_end_time = time.time()
|
||||
classification_time = classification_end_time - classification_start_time
|
||||
logging.info(f"意图分类耗时统计 - 总耗时: {classification_time:.2f}秒")
|
||||
# 解析输出
|
||||
try:
|
||||
# 调用LLM
|
||||
response = self._llm.invoke(formatted_prompt, False)
|
||||
|
||||
classification_end_time = time.time()
|
||||
classification_time = classification_end_time - classification_start_time
|
||||
logging.info(f"意图分类耗时统计 - 总耗时: {classification_time:.2f}秒")
|
||||
|
||||
# 尝试直接解析JSON响应
|
||||
parsed_output = classification_parser.parse(response.content.strip())
|
||||
return parsed_output
|
||||
@@ -319,12 +321,11 @@ class IntentRecognizer:
|
||||
keywords=keywords_str,
|
||||
chat_history=chat_history,
|
||||
context=context)
|
||||
|
||||
# 调用LLM
|
||||
response = self._llm.invoke(formatted_prompt, False)
|
||||
|
||||
# 解析输出
|
||||
try:
|
||||
# 调用LLM
|
||||
response = self._llm.invoke(formatted_prompt, False)
|
||||
|
||||
# 尝试直接解析JSON响应
|
||||
parsed_output = query_rewrite_parser.parse(response.content)
|
||||
rewrite_end_time = time.time()
|
||||
@@ -531,11 +532,11 @@ class IntentRecognizer:
|
||||
chat_history=json.dumps(chat_history,ensure_ascii=False),
|
||||
previous_slots=json.dumps(previous_slots,ensure_ascii=False),
|
||||
)
|
||||
|
||||
# 调用LLM
|
||||
response = self._llm.invoke(formatted_prompt, False)
|
||||
|
||||
try:
|
||||
# 调用LLM
|
||||
response = self._llm.invoke(formatted_prompt, False)
|
||||
|
||||
|
||||
# 尝试解析LLM响应
|
||||
parsed_output = slot_parser.parse(response.content)
|
||||
return parsed_output
|
||||
|
||||
@@ -46,7 +46,8 @@ classification_info="""【垂直领域分类】:
|
||||
示例:
|
||||
"这个文件用配网软件能打开吗?(隐含扩展名关联)",
|
||||
".bphq18 是什么类型的文件?",
|
||||
"用哪个软件打开.BDY3文件?"
|
||||
"用哪个软件打开.BDY3文件?",
|
||||
"BDD3是什么"
|
||||
2. 软件锁类:询问软件锁信息、锁注册号查询、许可证查询、锁激活问题等软件锁相关问题
|
||||
3. 安装下载类:安装下载咨询、组件(插件)选择、环境配置等
|
||||
4. 问题排查类:软件安装下载失败、报错,系统兼容性问题等
|
||||
@@ -77,6 +78,14 @@ classification_prompt="""
|
||||
"vertical_classification":"软件咨询",
|
||||
"sub_classification":"软件功能"
|
||||
}}
|
||||
|
||||
|
||||
用户输入2: BDD3是什么
|
||||
输出2:
|
||||
{{
|
||||
"vertical_classification":"安装下载注册",
|
||||
"sub_classification":"后缀名咨询"
|
||||
}}
|
||||
"""
|
||||
|
||||
query_rewrite_prompt = """
|
||||
|
||||
@@ -20,7 +20,6 @@ import requests
|
||||
API_KEY_LIST=[
|
||||
"sk-kvgfuqeqvpmfsccykyoohheshclcrtvjlnewratvrjpkpbkc",
|
||||
"sk-kzhxlqvqcxlnbdgnpalqnzumkmspepkttkgbophnkqanainw",
|
||||
"sk-bzttugqtlskrvguvhckwamdssvgmgnrqpsialpdbskfsyyak",
|
||||
"sk-tovmogiablsoeabwgqyvevpcfichyjpuzqdymmvksspdrtqt",
|
||||
"sk-yvyvoiegjrdlgihnxlaaznzdhnvpmfowtwmofomcodaoeaqs",
|
||||
"sk-vccwuaomxhjcszjhheipoqqmsnuetasiveombkyrptstesbi",
|
||||
|
||||
Reference in New Issue
Block a user