Skip to content

Commit

Permalink
update agentfabric requirement & fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
suluyana committed Dec 4, 2024
1 parent f038a09 commit a206624
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/agentfabric/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gradio==4.36.1
markdown-cjk-spacing
mdx_truly_sane_lists
modelscope-agent>=0.6.6
modelscope-agent>=0.7.2
modelscope_studio>=0.4.0
moviepy
pymdown-extensions
Expand Down
8 changes: 6 additions & 2 deletions modelscope_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ def _register_tool(self,
tool_cfg = tool[tool_name]
except StopIteration:
# If the tool is an empty dictionary, proceed to register the next tool.
print("Empty tool dictionary provided, skipping the registration of the current tool")
print(
'Empty tool dictionary provided, skipping the registration of the current tool'
)
return

# If the tool is a string, assign it directly to tool_name.
Expand All @@ -212,7 +214,9 @@ def _register_tool(self,

# If the tool_name is empty, skip the registration of the current tool.
if not tool_name:
print("No tool name provided, skipping the registration of the current tool")
print(
'No tool name provided, skipping the registration of the current tool'
)
return

if tool_name not in TOOL_REGISTRY and not self.use_tool_api:
Expand Down
21 changes: 13 additions & 8 deletions modelscope_agent/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ def __init__(self,
self._register_tool()

if not self.tool_name:
print("Skipping tool registration and status check because 'tool_name' is not defined or empty.")
print(
"Skipping tool registration and status check because 'tool_name' is not defined or empty."
)
return # When tool_name is an empty string, skip registration and status check.

max_retry = 10
Expand Down Expand Up @@ -375,7 +377,9 @@ def _register_tool(self):
try:
# Check if `tool_name` is defined and not empty.
if not self.tool_name:
print("Skipping tool registration because 'tool_name' is not defined or empty.")
print(
"Skipping tool registration because 'tool_name' is not defined or empty."
)
return # Return directly, skipping registration.

service_token = os.getenv('TOOL_MANAGER_AUTH', '')
Expand Down Expand Up @@ -432,8 +436,8 @@ def _check_tool_status(self):
return result['status']
except Exception as e:
raise RuntimeError(
f'Get error during checking status from tool manager service: {self.tool_name} {self.tenant_id}. detail {e}, {traceback.format_exc()}'
)
f'Get error during checking status from tool manager service: {self.tool_name} '
f'{self.tenant_id}. detail {e}, {traceback.format_exc()}')

def _get_tool_info(self):
try:
Expand All @@ -454,13 +458,14 @@ def _get_tool_info(self):
response.raise_for_status()
tool_info = ToolServiceProxy.parse_service_response(response)
# check required params
name = tool_info['name']
description = tool_info['description']
parameters = tool_info['parameters']
_ = tool_info['name']
_ = tool_info['description']
_ = tool_info['parameters']
return tool_info
except Exception as e:
raise RuntimeError(
f'Get error during getting tool info from tool manager, {self.tool_name} {self.tenant_id}. detail {e}, {traceback.format_exc()}'
f'Get error during getting tool info from tool manager, '
f'{self.tool_name} {self.tenant_id}. detail {e}, {traceback.format_exc()}'
)

def call(self, params: str, **kwargs):
Expand Down
9 changes: 6 additions & 3 deletions modelscope_agent/tools/utils/openapi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,14 @@ def openapi_schema_convert(schema: dict, auth: dict = {}):
host = schema.get('host', '') if schema else '' # Check if schema is None

if host:
schema = swagger_to_openapi(schema) if schema else {} # Call only if schema is not None
schema = swagger_to_openapi(schema) if schema else {
} # Call only if schema is not None

schema = jsonref.replace_refs(schema) if schema else {} # Call only if schema is not None
schema = jsonref.replace_refs(schema) if schema else {
} # Call only if schema is not None

servers = schema.get('servers', []) if schema else [] # Check if schema is None
servers = schema.get('servers', []) if schema else [
] # Check if schema is None

if servers:
servers_url = servers[0].get('url')
Expand Down

0 comments on commit a206624

Please sign in to comment.