Skip to content

Commit

Permalink
allow visit remote
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhangpurdue committed Nov 13, 2024
1 parent ba88896 commit c4a6218
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
1 change: 1 addition & 0 deletions apps/agentfabric/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion apps/agentfabric/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
43 changes: 22 additions & 21 deletions modelscope_agent/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c4a6218

Please sign in to comment.