Unverified Commit 2aa0cc2c authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Use config to set name and description if not present (#23473)

Use config to set name and descriptiob if not present
parent 21bd3be1
...@@ -260,6 +260,24 @@ class Tool: ...@@ -260,6 +260,24 @@ class Tool:
tool_class = custom_tool["tool_class"] tool_class = custom_tool["tool_class"]
tool_class = get_class_from_dynamic_module(tool_class, repo_id, use_auth_token=token, **hub_kwargs) tool_class = get_class_from_dynamic_module(tool_class, repo_id, use_auth_token=token, **hub_kwargs)
if len(tool_class.name) == 0:
tool_class.name = custom_tool["name"]
if tool_class.name != custom_tool["name"]:
logger.warn(
f"{tool_class.__name__} implements a different name in its configuration and class. Using the tool "
"configuration name."
)
tool_class.name = custom_tool["name"]
if len(tool_class.description) == 0:
tool_class.description = custom_tool["description"]
if tool_class.description != custom_tool["description"]:
logger.warn(
f"{tool_class.__name__} implements a different description in its configuration and class. Using the "
"tool configuration description."
)
tool_class.description = custom_tool["description"]
if remote: if remote:
return RemoteTool(model_repo_id, token=token, tool_class=tool_class) return RemoteTool(model_repo_id, token=token, tool_class=tool_class)
return tool_class(model_repo_id, token=token, **kwargs) return tool_class(model_repo_id, token=token, **kwargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment