From 333d3e0a6d04a4e4ba6c9f7b2a50b5fb02778d47 Mon Sep 17 00:00:00 2001 From: yhjun1026 <460342015@qq.com> Date: Thu, 1 Jun 2023 20:03:35 +0800 Subject: [PATCH] model server fix message model --- pilot/scene/chat_execution/out_parser.py | 8 +++++--- pilot/scene/chat_execution/prompt.py | 10 +++------- pilot/scene/chat_normal/prompt.py | 5 +++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pilot/scene/chat_execution/out_parser.py b/pilot/scene/chat_execution/out_parser.py index 4d8989292..2f8dd00b7 100644 --- a/pilot/scene/chat_execution/out_parser.py +++ b/pilot/scene/chat_execution/out_parser.py @@ -13,14 +13,16 @@ logger = build_logger("webserver", LOGDIR + "DbChatOutputParser.log") class PluginAction(NamedTuple): command: Dict - thoughts: Dict + speak: str + reasoning:str + thoughts: str class PluginChatOutputParser(BaseOutputParser): def parse_prompt_response(self, model_out_text) -> T: response = json.loads(super().parse_prompt_response(model_out_text)) - command, thoughts = response["command"], response["thoughts"] - return PluginAction(command, thoughts) + command, thoughts, speak, reasoning = response["command"], response["thoughts"], response["speak"], response["reasoning"] + return PluginAction(command, speak, reasoning, thoughts) def parse_view_response(self, speak, data) -> str: ### tool out data to table view diff --git a/pilot/scene/chat_execution/prompt.py b/pilot/scene/chat_execution/prompt.py index 2091a6469..98ba1652c 100644 --- a/pilot/scene/chat_execution/prompt.py +++ b/pilot/scene/chat_execution/prompt.py @@ -37,13 +37,9 @@ Ensure the response is correct json and can be parsed by Python json.loads """ RESPONSE_FORMAT = { - "thoughts": { - "text": "thought", - "reasoning": "reasoning", - "plan": "- short bulleted\n- list that conveys\n- long-term plan", - "criticism": "constructive self-criticism", - "speak": "thoughts summary to say to user", - }, + "thoughts": "thought text", + "reasoning": "reasoning", + "speak": "thoughts summary to say to user", "command": {"name": "command name", "args": {"arg name": "value"}}, } diff --git a/pilot/scene/chat_normal/prompt.py b/pilot/scene/chat_normal/prompt.py index 2ab387952..55514dffa 100644 --- a/pilot/scene/chat_normal/prompt.py +++ b/pilot/scene/chat_normal/prompt.py @@ -8,6 +8,8 @@ from pilot.common.schema import SeparatorStyle from pilot.scene.chat_normal.out_parser import NormalChatOutputParser +PROMPT_SCENE_DEFINE = """A chat between a curious user and an artificial intelligence assistant, who very familiar with database related knowledge. + The assistant gives helpful, detailed, professional and polite answers to the user's questions. """ CFG = Config() @@ -19,7 +21,7 @@ prompt = PromptTemplate( template_scene=ChatScene.ChatNormal.value, input_variables=["input"], response_format=None, - template_define=None, + template_define=PROMPT_SCENE_DEFINE, template=None, stream_out=PROMPT_NEED_NEED_STREAM_OUT, output_parser=NormalChatOutputParser( @@ -27,5 +29,4 @@ prompt = PromptTemplate( ), ) - CFG.prompt_templates.update({prompt.template_scene: prompt})