feat(agent): intent agent v2

This commit is contained in:
yhjun1026
2024-08-19 20:48:43 +08:00
parent 78c3f2a7eb
commit 3573d8a935
4 changed files with 39 additions and 38 deletions

View File

@@ -305,12 +305,12 @@ class GptsMemory:
none_goal_count = 1 none_goal_count = 1
for message in messages: for message in messages:
if ( if message.sender in [
message.sender == "Intent Recognition Expert" "Intent Recognition Expert",
or message.receiver == "Intent Recognition Expert" "App Link",
): ] or message.receiver in ["Intent Recognition Expert", "App Link"]:
if ( if (
message.sender == "Intent Recognition Expert" message.sender in ["Intent Recognition Expert", "App Link"]
and message.receiver == "AppLauncher" and message.receiver == "AppLauncher"
): ):
app_link_message = message app_link_message = message

View File

@@ -57,10 +57,7 @@ class IntentRecognitionAction(Action[IntentRecognitionInput]):
out_put_schema = { out_put_schema = {
"intent": "[The recognized intent is placed here]", "intent": "[The recognized intent is placed here]",
"app_code": "[App code in selected intent]", "app_code": "[App code in selected intent]",
"slots": { "slots": {"意图定义中槽位属性1": "具体值", "意图定义中槽位属性2": "具体值"},
"attribute name 1": "[The value of the slot attribute 1 in intent define]",
"attribute name 2": "[The value of the slot attribute 2 in intent define]",
},
"ask_user": "If you want the user to supplement slot data, ask the user a question", "ask_user": "If you want the user to supplement slot data, ask the user a question",
"user_input": "[Complete instructions generated based on intent and slot]", "user_input": "[Complete instructions generated based on intent and slot]",
} }
@@ -121,7 +118,6 @@ class IntentRecognitionAction(Action[IntentRecognitionInput]):
next_speakers=next_speakers, next_speakers=next_speakers,
) )
next_speakers = []
if intent.app_code and len(intent.app_code) > 0: if intent.app_code and len(intent.app_code) > 0:
from dbgpt.serve.agent.agents.expand.app_start_assisant_agent import ( from dbgpt.serve.agent.agents.expand.app_start_assisant_agent import (
StartAppAssistantAgent, StartAppAssistantAgent,
@@ -133,12 +129,19 @@ class IntentRecognitionAction(Action[IntentRecognitionInput]):
"app_code": intent.app_code, "app_code": intent.app_code,
"app_name": intent.intent, "app_name": intent.intent,
"app_desc": intent.user_input, "app_desc": intent.user_input,
"app_logo": "",
"status": "TODO",
} }
return ActionOutput( return ActionOutput(
is_exe_success=True, is_exe_success=True,
content=json.dumps(app_link_param, ensure_ascii=False), content=json.dumps(app_link_param, ensure_ascii=False),
view=await self.render_protocal.display(content=app_link_param), view=await self.render_protocal.display(
content={
"app_code": intent.app_code,
"app_name": intent.intent,
"app_desc": intent.user_input,
"app_logo": "",
"status": "TODO",
}
),
next_speakers=next_speakers, next_speakers=next_speakers,
) )

View File

@@ -16,7 +16,7 @@ class LinkAppAssistantAgent(ConversableAgent):
key="dbgpt_ant_agent_agents_app_link_assistant_agent_profile_name", key="dbgpt_ant_agent_agents_app_link_assistant_agent_profile_name",
), ),
role=DynConfig( role=DynConfig(
"App Selector", "App Link",
category="agent", category="agent",
key="dbgpt_ant_agent_agents_app_link_assistant_agent_profile_role", key="dbgpt_ant_agent_agents_app_link_assistant_agent_profile_role",
), ),

View File

@@ -24,32 +24,30 @@ RETRY_GOAL_EN = (
RETRY_GOAL_ZH = "阅读下面用户提供的最近消息内容,并把当前用户输入信息提取补充到最近消息中的意图信息里,并返回补充后的意图信息。" RETRY_GOAL_ZH = "阅读下面用户提供的最近消息内容,并把当前用户输入信息提取补充到最近消息中的意图信息里,并返回补充后的意图信息。"
CONSTRAINTS_EN = [ CONSTRAINTS_EN = [
"According to the user input information, select and match from the given intent definition. " "Strictly define the output based on the given intent. Do not generate the intent and "
"If no intent is matched, 'intent' and 'app_code' will be output as empty. Do not generate " "slot attributes by yourself. If the intent does not define a slot, the output should "
"intent and slot attributes by yourself.", "not include the slot.",
"The selected intent does not have a slots attribute defined, so make sure the output json " "Select the appropriate intent to answer the user's question based on user input. "
"does not include the 'slots' attribute.", "If no intent can be matched, the output of app_code' will be empty.",
"Extract the value of the slot attribute in the intent definition from user input and historical " "If there is no 'Slots' definition in the selected intent definition, make sure the "
"dialogue information. If the target information corresponding to the slot attribute cannot be " "output slot content is empty and do not create any slot information yourself.",
"obtained, the slot value output is empty.", "If there is a 'Slots' definition in the selected intent definition, extract the value "
"When extracting slot values, please be careful to only obtain the valid value part and do not " "of the specific slot attribute from the user input. If the value of the slot attribute "
"fill in auxiliary descriptions or attributes.", "cannot be obtained, ensure that the slot attribute value output is empty.",
"Make sure that the slot attributes defined by intention will output all the slot attributes " "When extracting the slot value, please be careful to only obtain the valid value part. "
"given by the definition regardless of whether the value is obtained. If the value is not found, " "Do not fill in auxiliary descriptions, attributes, prompts or description information, "
"the slot name and null value will be output.", "and do not appear content like 'not provided by the user'.",
"Please ensure that if the content of the intent slot definition is not provided in the user " "When the complete slot attribute value defined by the intent cannot be collected, a "
"question, the slot value must be empty, and do not fill in invalid information such as 'user " "prompt will be proactively sent to the user to remind the user to supplement the missing "
"not provided' in the slot value.", "slot data.",
"If the information extracted from the user's question content does not completely correspond to "
"the matched intention slot, a new question will be generated to ask the user and prompt the user "
"to supplement the missing slot data.",
] ]
CONSTRAINTS_ZH = [ CONSTRAINTS_ZH = [
"根据用户输入信息,从给出的意图定义中进行选择匹配,无法匹配到任何意图'intent''app_code'都输出为空,不要输出任何未定义的意图.", "严格根给出的意图定义输出,不要自行生成意图和槽位属性,意图没有定义槽位则输出也不应该包含槽位.",
"请确保按意图定义输出槽位属性,不要自行创造任何槽位属性,如果意图定义没有槽位属性,则确保槽位输出位空" "根据用户输入选择合适的意图回答用户问题如无法匹配到任何意图app_code'输出为空.",
"从用户输入和历史对话信息中提取意图定义中槽位属性的值,如果无法获取到槽位属性的值,则确保槽位值输出空,不要在槽位值里输出提示或者描述信息,不要出现类似'用户未提供'这样的内容.", "如果选择的意图定义中没有'Slots'定义,则确保输出槽位内容为空,不要自行创造任何槽位信息",
"槽位值提取时请注意只获取有效值部分,不要填入辅助描述或定语", "如果选择的意图定义中有'Slots'定义,从用户输入中提取具体槽位属性的值,如果无法获取到槽位属性的值,则确保槽位属性值输出空.",
"如果无法收集到完整的意图定义的槽位属性的值,主动像用户发起提示,提醒用户补充缺槽位数据.", "槽位值提取时请注意只获取有效值部分,不要填入辅助描述、定语、提示或者描述信息,不要出现类似'用户未提供'这样的内容.",
"无法收集到完整的意图定义的槽位属性值时,主动像用户发起提示,提醒用户补充缺槽位数据.",
] ]
RETRY_CONSTRAINTS_EN = [ RETRY_CONSTRAINTS_EN = [