mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-07 12:00:46 +00:00
多轮对话使用插件
This commit is contained in:
@@ -45,6 +45,7 @@ def execute_ai_response_json(
|
||||
except (json.JSONDecodeError, ValueError, AttributeError) as e:
|
||||
raise NotCommands("非可执行命令结构")
|
||||
command_name, arguments = get_command(assistant_reply_json)
|
||||
|
||||
if cfg.speak_mode:
|
||||
say_text(f"I want to execute {command_name}")
|
||||
|
||||
@@ -105,11 +106,16 @@ def execute_command(
|
||||
or command_name == command["name"].lower()
|
||||
):
|
||||
try:
|
||||
|
||||
# 删除非定义参数
|
||||
diff_ags = list(set(arguments.keys()).difference(set(command['args'].keys())))
|
||||
for arg_name in arguments.keys():
|
||||
if arg_name in diff_ags:
|
||||
del arguments[arg_name]
|
||||
print(str(arguments))
|
||||
return command["function"](**arguments)
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
raise NotCommands("非可用命令" + command)
|
||||
raise NotCommands("非可用命令" + command_name)
|
||||
|
||||
|
||||
def get_command(response_json: Dict):
|
||||
|
@@ -1,3 +1,5 @@
|
||||
|
||||
class NotCommands(Exception):
|
||||
def __init__(self, message):
|
||||
super().__init__(message)
|
||||
self.message = message
|
Reference in New Issue
Block a user