Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
21ade71b
Unverified
Commit
21ade71b
authored
Jan 23, 2024
by
Yeuoly
Committed by
GitHub
Jan 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: agent strategy (#2141)
parent
23e02d8e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
23 deletions
+26
-23
application_manager.py
api/core/application_manager.py
+26
-23
No files found.
api/core/application_manager.py
View file @
21ade71b
...
...
@@ -419,8 +419,9 @@ class ApplicationManager:
datasets
=
{
'strategy'
:
'router'
,
'datasets'
:
[]}
if
'agent_mode'
in
copy_app_model_config_dict
and
copy_app_model_config_dict
[
'agent_mode'
]
\
and
'enabled'
in
copy_app_model_config_dict
[
'agent_mode'
]
and
copy_app_model_config_dict
[
'agent_mode'
][
'enabled'
]:
and
'enabled'
in
copy_app_model_config_dict
[
'agent_mode'
]
\
and
copy_app_model_config_dict
[
'agent_mode'
][
'enabled'
]:
agent_dict
=
copy_app_model_config_dict
.
get
(
'agent_mode'
,
{})
agent_strategy
=
agent_dict
.
get
(
'strategy'
,
'cot'
)
...
...
@@ -464,29 +465,31 @@ class ApplicationManager:
dataset_id
=
tool_item
[
'id'
]
dataset_ids
.
append
(
dataset_id
)
if
'strategy'
in
copy_app_model_config_dict
[
'agent_mode'
]
and
\
copy_app_model_config_dict
[
'agent_mode'
][
'strategy'
]
not
in
[
'react_router'
,
'router'
]:
agent_prompt
=
agent_dict
.
get
(
'prompt'
,
None
)
or
{}
# check model mode
model_mode
=
copy_app_model_config_dict
.
get
(
'model'
,
{})
.
get
(
'mode'
,
'completion'
)
if
model_mode
==
'completion'
:
agent_prompt_entity
=
AgentPromptEntity
(
first_prompt
=
agent_prompt
.
get
(
'first_prompt'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'completion'
][
'prompt'
]),
next_iteration
=
agent_prompt
.
get
(
'next_iteration'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'completion'
][
'agent_scratchpad'
]),
)
else
:
agent_prompt_entity
=
AgentPromptEntity
(
first_prompt
=
agent_prompt
.
get
(
'first_prompt'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'chat'
][
'prompt'
]),
next_iteration
=
agent_prompt
.
get
(
'next_iteration'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'chat'
][
'agent_scratchpad'
]),
)
agent_prompt
=
agent_dict
.
get
(
'prompt'
,
None
)
or
{}
# check model mode
model_mode
=
copy_app_model_config_dict
.
get
(
'model'
,
{})
.
get
(
'mode'
,
'completion'
)
if
model_mode
==
'completion'
:
agent_prompt_entity
=
AgentPromptEntity
(
first_prompt
=
agent_prompt
.
get
(
'first_prompt'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'completion'
][
'prompt'
])
,
next_iteration
=
agent_prompt
.
get
(
'next_iteration'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'completion'
][
'agent_scratchpad'
]),
properties
[
'agent'
]
=
AgentEntity
(
provider
=
properties
[
'model_config'
]
.
provider
,
model
=
properties
[
'model_config'
]
.
model
,
strategy
=
strategy
,
prompt
=
agent_prompt_entity
,
tools
=
agent_tools
,
max_iteration
=
agent_dict
.
get
(
'max_iteration'
,
5
)
)
else
:
agent_prompt_entity
=
AgentPromptEntity
(
first_prompt
=
agent_prompt
.
get
(
'first_prompt'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'chat'
][
'prompt'
]),
next_iteration
=
agent_prompt
.
get
(
'next_iteration'
,
REACT_PROMPT_TEMPLATES
[
'english'
][
'chat'
][
'agent_scratchpad'
]),
)
properties
[
'agent'
]
=
AgentEntity
(
provider
=
properties
[
'model_config'
]
.
provider
,
model
=
properties
[
'model_config'
]
.
model
,
strategy
=
strategy
,
prompt
=
agent_prompt_entity
,
tools
=
agent_tools
,
max_iteration
=
agent_dict
.
get
(
'max_iteration'
,
5
)
)
if
len
(
dataset_ids
)
>
0
:
# dataset configs
...
...
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