diff --git a/apps/agentfabric/config_utils.py b/apps/agentfabric/config_utils.py index 4ea06826..5b3a277e 100644 --- a/apps/agentfabric/config_utils.py +++ b/apps/agentfabric/config_utils.py @@ -169,6 +169,7 @@ def parse_configuration(uuid_str='', use_tool_api=False): if 'is_openapi' in value and value['is_openapi']: available_plugin_list.append(key) + tool_cfg[key]['use'] = False elif value['use']: available_tool_list.append(key) diff --git a/apps/agentfabric/server.py b/apps/agentfabric/server.py index 463e4e21..c75edb24 100644 --- a/apps/agentfabric/server.py +++ b/apps/agentfabric/server.py @@ -649,7 +649,8 @@ def openapi_test_parser(uuid_str): result = openapi_schema_instance.call( tool_params, **{ 'tool_name': tool_name, - 'credentials': credentials + 'credentials': credentials, + 'is_test': True }) if not result: return jsonify({ diff --git a/modelscope_agent/tools/base.py b/modelscope_agent/tools/base.py index a935de6c..048464af 100644 --- a/modelscope_agent/tools/base.py +++ b/modelscope_agent/tools/base.py @@ -694,29 +694,30 @@ def call(self, params: str, **kwargs): for name, value in path_params.items(): url = url.replace(f'{{{name}}}', f'{value}') + credentials = kwargs.get('credentials', {}) + header = self._parse_credentials(credentials, header) + try: # visit tool node to call tool - # if self.is_remote: - # response = requests.post( - # f'{self.openapi_service_manager_url}/execute_openapi', - # json={ - # 'url': url, - # 'params': query_params, - # 'headers': header, - # 'method': method, - # 'cookies': cookies, - # 'data': data - # }, - # headers=headers) - # logger.query_info( - # message=f'calling tool message {response.json()}') - # - # response.raise_for_status() - # else: - credentials = kwargs.get('credentials', {}) - header = self._parse_credentials(credentials, header) - response = execute_api_call(url, method, header, query_params, - data, cookies) + if self.is_remote and not kwargs.get('is_test', False): + response = requests.post( + f'{self.openapi_service_manager_url}/execute_openapi', + json={ + 'url': url, + 'params': query_params, + 'headers': header, + 'method': method, + 'cookies': cookies, + 'data': data + }, + headers=headers) + logger.query_info( + message=f'calling tool message {response.json()}') + + response.raise_for_status() + else: + response = execute_api_call(url, method, header, query_params, + data, cookies) return OpenapiServiceProxy.parse_service_response(response) except Exception as e: raise RuntimeError(