Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
2aa0cc2c
Unverified
Commit
2aa0cc2c
authored
May 19, 2023
by
Sylvain Gugger
Committed by
GitHub
May 19, 2023
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
src/transformers/tools/base.py
src/transformers/tools/base.py
+18
-0
No files found.
src/transformers/tools/base.py
View file @
2aa0cc2c
...
...
@@ -260,6 +260,24 @@ class Tool:
tool_class
=
custom_tool
[
"tool_class"
]
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
:
return
RemoteTool
(
model_repo_id
,
token
=
token
,
tool_class
=
tool_class
)
return
tool_class
(
model_repo_id
,
token
=
token
,
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment