Skip to content

Commit

Permalink
fix nested reference error
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhangpurdue committed Nov 13, 2024
1 parent ad9bce4 commit f21507e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion modelscope_agent/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def _verify_args(self, params: str, api_info) -> Union[str, dict]:
if 'required' in param and param['required']:

current = {}
current_test = copy.deepcopy(params_json)
current_test = deepcopy(params_json)
parts = param['name'].split('.')
for i, part in enumerate(parts):
if part not in current:
Expand Down Expand Up @@ -714,6 +714,7 @@ def call(self, params: str, **kwargs):
response = requests.post(
f'{self.openapi_service_manager_url}/execute_openapi',
json={
'openapi_name': self.openapi_remote_name,
'url': url,
'params': query_params,
'headers': header,
Expand Down
6 changes: 3 additions & 3 deletions modelscope_agent/tools/utils/openapi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ def parse_nested_parameters(param_name, param_info, parameters_list, content):


# openapi_schema_convert,register to tool_config.json
def extract_references(schema_content):
def extract_references(schema_content, index=0):
references = []
if isinstance(schema_content, dict):
if '$ref' in schema_content:
references.append(schema_content['$ref'])
for key, value in schema_content.items():
references.extend(extract_references(value))
references.extend(extract_references(value, index + 1))
# if properties exist, record the schema content in references and deal later
if 'properties' in schema_content:
if 'properties' in schema_content and index == 0:
references.append(schema_content)
elif isinstance(schema_content, list):
for item in schema_content:
Expand Down

0 comments on commit f21507e

Please sign in to comment.