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
aeb5a08a
Unverified
Commit
aeb5a08a
authored
Aug 04, 2023
by
Sylvain Gugger
Committed by
GitHub
Aug 04, 2023
Browse files
Add offline mode for agents (#25226)
* Add offline mode for agents * Disable second check too
parent
bff4313b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
src/transformers/tools/agents.py
src/transformers/tools/agents.py
+16
-11
No files found.
src/transformers/tools/agents.py
View file @
aeb5a08a
...
@@ -25,7 +25,7 @@ import requests
...
@@ -25,7 +25,7 @@ import requests
from
huggingface_hub
import
HfFolder
,
hf_hub_download
,
list_spaces
from
huggingface_hub
import
HfFolder
,
hf_hub_download
,
list_spaces
from
..models.auto
import
AutoTokenizer
from
..models.auto
import
AutoTokenizer
from
..utils
import
is_openai_available
,
is_torch_available
,
logging
from
..utils
import
is_offline_mode
,
is_openai_available
,
is_torch_available
,
logging
from
.base
import
TASK_MAPPING
,
TOOL_CONFIG_FILE
,
Tool
,
load_tool
,
supports_remote
from
.base
import
TASK_MAPPING
,
TOOL_CONFIG_FILE
,
Tool
,
load_tool
,
supports_remote
from
.prompts
import
CHAT_MESSAGE_PROMPT
,
download_prompt
from
.prompts
import
CHAT_MESSAGE_PROMPT
,
download_prompt
from
.python_interpreter
import
evaluate
from
.python_interpreter
import
evaluate
...
@@ -75,6 +75,10 @@ HUGGINGFACE_DEFAULT_TOOLS_FROM_HUB = [
...
@@ -75,6 +75,10 @@ HUGGINGFACE_DEFAULT_TOOLS_FROM_HUB = [
def
get_remote_tools
(
organization
=
"huggingface-tools"
):
def
get_remote_tools
(
organization
=
"huggingface-tools"
):
if
is_offline_mode
():
logger
.
info
(
"You are in offline mode, so remote tools are not available."
)
return
{}
spaces
=
list_spaces
(
author
=
organization
)
spaces
=
list_spaces
(
author
=
organization
)
tools
=
{}
tools
=
{}
for
space_info
in
spaces
:
for
space_info
in
spaces
:
...
@@ -105,6 +109,7 @@ def _setup_default_tools():
...
@@ -105,6 +109,7 @@ def _setup_default_tools():
description
=
tool_class
.
description
description
=
tool_class
.
description
HUGGINGFACE_DEFAULT_TOOLS
[
tool_class
.
name
]
=
PreTool
(
task
=
task_name
,
description
=
description
,
repo_id
=
None
)
HUGGINGFACE_DEFAULT_TOOLS
[
tool_class
.
name
]
=
PreTool
(
task
=
task_name
,
description
=
description
,
repo_id
=
None
)
if
not
is_offline_mode
():
for
task_name
in
HUGGINGFACE_DEFAULT_TOOLS_FROM_HUB
:
for
task_name
in
HUGGINGFACE_DEFAULT_TOOLS_FROM_HUB
:
found
=
False
found
=
False
for
tool_name
,
tool
in
remote_tools
.
items
():
for
tool_name
,
tool
in
remote_tools
.
items
():
...
...
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