From 6c90740fbe23f91a530945e6a2b9a461e7ee4c53 Mon Sep 17 00:00:00 2001 From: "tuyang.yhj" Date: Wed, 5 Jul 2023 11:52:19 +0800 Subject: [PATCH] WEB API independent --- pilot/scene/chat_db/auto_execute/out_parser.py | 7 +++++-- pilot/scene/chat_execution/out_parser.py | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pilot/scene/chat_db/auto_execute/out_parser.py b/pilot/scene/chat_db/auto_execute/out_parser.py index 136c74429..5ae3cc111 100644 --- a/pilot/scene/chat_db/auto_execute/out_parser.py +++ b/pilot/scene/chat_db/auto_execute/out_parser.py @@ -27,8 +27,11 @@ class DbChatOutputParser(BaseOutputParser): clean_str = super().parse_prompt_response(model_out_text) print("clean prompt response:", clean_str) response = json.loads(clean_str) - - sql, thoughts = response["sql"], response["thoughts"] + for key in sorted(response): + if key.strip() == 'sql': + sql =response[key] + if key.strip() == 'thoughts': + thoughts =response[key] return SqlAction(sql, thoughts) def parse_view_response(self, speak, data) -> str: diff --git a/pilot/scene/chat_execution/out_parser.py b/pilot/scene/chat_execution/out_parser.py index 565d54c5e..1124fa528 100644 --- a/pilot/scene/chat_execution/out_parser.py +++ b/pilot/scene/chat_execution/out_parser.py @@ -28,11 +28,13 @@ class PluginChatOutputParser(BaseOutputParser): except Exception as e: raise ValueError("model server out not fllow the prompt!") - command, thoughts, speak = ( - response["command"], - response["thoughts"], - response["speak"], - ) + for key in sorted(response): + if key.strip() == 'command': + command =response[key] + if key.strip() == 'thoughts': + thoughts =response[key] + if key.strip() == 'speak': + speak =response[key] return PluginAction(command, speak, thoughts) def parse_view_response(self, speak, data) -> str: