Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhangpurdue committed Oct 18, 2024
1 parent 6229508 commit e8c9247
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions modelscope_agent/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,11 @@ def parse_service_response(response):
else:
response_data = response
# Extract the 'output' field from the response
output_data = response_data.get('output', {})
if 'output' in response_data:
output_data = response_data['output']
else:
output_data = response_data

return output_data
except json.JSONDecodeError:
# Handle the case where response is not JSON or cannot be decoded
Expand Down Expand Up @@ -652,6 +656,7 @@ def call(self, params: str, **kwargs):
method = api_info['method']
header = api_info['header']
path_params = {}
query_params = {}
cookies = {}
data = {}
for parameter in api_info.get('parameters', []):
Expand All @@ -660,7 +665,7 @@ def call(self, params: str, **kwargs):
path_params[parameter['name']] = value

elif parameter['in'] == 'query':
params[parameter['name']] = value
query_params[parameter['name']] = value

elif parameter['in'] == 'cookie':
cookies[parameter['name']] = value
Expand All @@ -679,7 +684,7 @@ def call(self, params: str, **kwargs):
f'{self.openapi_service_manager_url}/execute_openapi',
json={
'url': url,
'params': params,
'params': query_params,
'headers': header,
'method': method,
'cookies': cookies,
Expand All @@ -693,8 +698,8 @@ def call(self, params: str, **kwargs):
else:
credentials = kwargs.get('credentials', {})
header = self._parse_credentials(credentials, header)
response = execute_api_call(url, method, header, params, data,
cookies)
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
1 change: 1 addition & 0 deletions modelscope_agent/tools/utils/openapi_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

import jsonref
import requests


Expand Down

0 comments on commit e8c9247

Please sign in to comment.