From 27f8fac5846ae16546173f5a883ef0901b3936f5 Mon Sep 17 00:00:00 2001 From: Zhicheng Zhang Date: Wed, 13 Nov 2024 13:58:03 +0800 Subject: [PATCH] fix openapi bugs in agentfabric --- apps/agentfabric/appBot.py | 10 +++++----- apps/agentfabric/config_utils.py | 10 +++++----- apps/agentfabric/server.py | 5 +---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/apps/agentfabric/appBot.py b/apps/agentfabric/appBot.py index 1336fffbd..d1b3b440e 100644 --- a/apps/agentfabric/appBot.py +++ b/apps/agentfabric/appBot.py @@ -121,11 +121,11 @@ def send_message(chatbot, input, _state, _user_token): if 'user_agent' not in _state: init_user(_state, _user_token) - kwargs = { - name.lower(): os.getenv(value.value) - for name, value in ApiNames.__members__.items() - } - + # kwargs = { + # name.lower(): os.getenv(value.value) + # for name, value in ApiNames.__members__.items() + # } + kwargs = {} # 将发送的消息添加到聊天历史 _uuid_str = check_uuid(uuid_str) user_agent = _state['user_agent'] diff --git a/apps/agentfabric/config_utils.py b/apps/agentfabric/config_utils.py index e3264cc48..c9a621260 100644 --- a/apps/agentfabric/config_utils.py +++ b/apps/agentfabric/config_utils.py @@ -157,6 +157,8 @@ def parse_configuration(uuid_str='', use_tool_api=False): tools_info = builder_cfg.tools available_tool_list = [] + available_plugin_list = [] + for key, value in tools_info.items(): if key in tool_cfg: tool_cfg[key]['use'] = value['use'] @@ -166,13 +168,11 @@ def parse_configuration(uuid_str='', use_tool_api=False): tool_cfg[key] = value if value['use']: available_tool_list.append(key) + if value['is_openapi']: + available_plugin_list.append(key) plugin_cfg = {} - available_plugin_list = [] - if use_tool_api and getattr(builder_cfg, 'openapi_list', None): - available_plugin_list = builder_cfg.openapi_list - else: - available_plugin_list = [] + if len(available_plugin_list) == 0: openapi_plugin_file = get_user_openapi_plugin_cfg_file(uuid_str) openapi_plugin_cfg_file_temp = './config/openapi_plugin_config.json' if os.path.exists(openapi_plugin_file): diff --git a/apps/agentfabric/server.py b/apps/agentfabric/server.py index baa9f35e2..463e4e21f 100644 --- a/apps/agentfabric/server.py +++ b/apps/agentfabric/server.py @@ -404,10 +404,7 @@ def preview_chat(uuid_str, session_str): file_paths.append(file_path) logger.info(f'/preview/chat/{uuid_str}/{session_str}: files: {file_paths}') # Generating the kwargs dictionary - kwargs = { - name.lower(): os.getenv(value.value) - for name, value in ApiNames.__members__.items() - } + kwargs = {} def generate(): try: