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
e1a9e0ac
Unverified
Commit
e1a9e0ac
authored
Feb 05, 2024
by
Yeuoly
Committed by
GitHub
Feb 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: missing variables in agent prompt (#2395)
parent
5e145c1c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
assistant_app_runner.py
api/core/app_runner/assistant_app_runner.py
+1
-0
assistant_cot_runner.py
api/core/features/assistant_cot_runner.py
+19
-1
No files found.
api/core/app_runner/assistant_app_runner.py
View file @
e1a9e0ac
...
...
@@ -222,6 +222,7 @@ class AssistantApplicationRunner(AppRunner):
conversation
=
conversation
,
message
=
message
,
query
=
query
,
inputs
=
inputs
,
)
elif
agent_entity
.
strategy
==
AgentEntity
.
Strategy
.
FUNCTION_CALLING
:
assistant_fc_runner
=
AssistantFunctionCallApplicationRunner
(
...
...
api/core/features/assistant_cot_runner.py
View file @
e1a9e0ac
...
...
@@ -20,6 +20,7 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
def
run
(
self
,
conversation
:
Conversation
,
message
:
Message
,
query
:
str
,
inputs
:
Dict
[
str
,
str
],
)
->
Union
[
Generator
,
LLMResult
]:
"""
Run Cot agent application
...
...
@@ -35,6 +36,11 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
if
'Observation'
not
in
app_orchestration_config
.
model_config
.
stop
:
app_orchestration_config
.
model_config
.
stop
.
append
(
'Observation'
)
# override inputs
inputs
=
inputs
or
{}
instruction
=
self
.
app_orchestration_config
.
prompt_template
.
simple_prompt_template
instruction
=
self
.
_fill_in_inputs_from_external_data_tools
(
instruction
,
inputs
)
iteration_step
=
1
max_iteration_steps
=
min
(
self
.
app_orchestration_config
.
agent
.
max_iteration
,
5
)
+
1
...
...
@@ -108,7 +114,7 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
tools
=
prompt_messages_tools
,
agent_scratchpad
=
agent_scratchpad
,
agent_prompt_message
=
app_orchestration_config
.
agent
.
prompt
,
instruction
=
app_orchestration_config
.
prompt_template
.
simple_prompt_template
,
instruction
=
instruction
,
input
=
query
)
...
...
@@ -300,6 +306,18 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
system_fingerprint
=
''
),
PublishFrom
.
APPLICATION_MANAGER
)
def
_fill_in_inputs_from_external_data_tools
(
self
,
instruction
:
str
,
inputs
:
dict
)
->
str
:
"""
fill in inputs from external data tools
"""
for
key
,
value
in
inputs
.
items
():
try
:
instruction
=
instruction
.
replace
(
f
'{{{{{key}}}}}'
,
str
(
value
))
except
Exception
as
e
:
continue
return
instruction
def
_extract_response_scratchpad
(
self
,
content
:
str
)
->
AgentScratchpadUnit
:
"""
extract response from llm response
...
...
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