Skip to content

Commit

Permalink
make sure the data is structed in openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhangpurdue committed Nov 11, 2024
1 parent d03efe3 commit f9a4e86
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modelscope_agent/tools/utils/openapi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@

def execute_api_call(url: str, method: str, headers: dict, params: dict,
data: dict, cookies: dict):

def structure_json(flat_json):
structured = {}

for key, value in flat_json.items():
parts = key.split('.')
current = structured

for i, part in enumerate(parts):
if i == len(parts) - 1:
current[part] = value
else:
if part not in current:
current[part] = {}
current = current[part]

return structured

if data:
data = structure_json(data)
try:
print('url:', url)
print('headers:', headers)
Expand Down

0 comments on commit f9a4e86

Please sign in to comment.