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
770a1275
Unverified
Commit
770a1275
authored
May 16, 2023
by
Ivan Sedykh
Committed by
GitHub
May 16, 2023
Browse files
Fix chat prompt in HFAgent (#23335)
fix chat prompts
parent
466af1a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/tools/agents.py
src/transformers/tools/agents.py
+2
-2
No files found.
src/transformers/tools/agents.py
View file @
770a1275
...
@@ -198,7 +198,7 @@ class Agent:
...
@@ -198,7 +198,7 @@ class Agent:
def
__init__
(
self
,
chat_prompt_template
=
None
,
run_prompt_template
=
None
,
additional_tools
=
None
):
def
__init__
(
self
,
chat_prompt_template
=
None
,
run_prompt_template
=
None
,
additional_tools
=
None
):
_setup_default_tools
()
_setup_default_tools
()
self
.
chat_prompt_template
=
CHAT_
MESSAGE_PROMPT
if
chat_prompt_template
is
None
else
chat_prompt_template
self
.
chat_prompt_template
=
CHAT_
PROMPT_TEMPLATE
if
chat_prompt_template
is
None
else
chat_prompt_template
self
.
run_prompt_template
=
RUN_PROMPT_TEMPLATE
if
run_prompt_template
is
None
else
run_prompt_template
self
.
run_prompt_template
=
RUN_PROMPT_TEMPLATE
if
run_prompt_template
is
None
else
run_prompt_template
self
.
_toolbox
=
HUGGINGFACE_DEFAULT_TOOLS
.
copy
()
self
.
_toolbox
=
HUGGINGFACE_DEFAULT_TOOLS
.
copy
()
if
additional_tools
is
not
None
:
if
additional_tools
is
not
None
:
...
@@ -229,7 +229,7 @@ class Agent:
...
@@ -229,7 +229,7 @@ class Agent:
description
=
"
\n
"
.
join
([
f
"-
{
name
}
:
{
tool
.
description
}
"
for
name
,
tool
in
self
.
toolbox
.
items
()])
description
=
"
\n
"
.
join
([
f
"-
{
name
}
:
{
tool
.
description
}
"
for
name
,
tool
in
self
.
toolbox
.
items
()])
if
chat_mode
:
if
chat_mode
:
if
self
.
chat_history
is
None
:
if
self
.
chat_history
is
None
:
prompt
=
CHAT_PROMPT_TEMPLATE
.
replace
(
"<<all_tools>>"
,
description
)
prompt
=
self
.
chat_prompt_template
.
replace
(
"<<all_tools>>"
,
description
)
else
:
else
:
prompt
=
self
.
chat_history
prompt
=
self
.
chat_history
prompt
+=
CHAT_MESSAGE_PROMPT
.
replace
(
"<<task>>"
,
task
)
prompt
+=
CHAT_MESSAGE_PROMPT
.
replace
(
"<<task>>"
,
task
)
...
...
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