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
f3219ff1
Unverified
Commit
f3219ff1
authored
May 23, 2023
by
John Wang
Committed by
GitHub
May 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: template string in template error (#162)
parent
219011b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
completion.py
api/core/completion.py
+15
-2
No files found.
api/core/completion.py
View file @
f3219ff1
...
...
@@ -151,6 +151,11 @@ And answer according to the language of the user's question.
if
chain_output
:
inputs
[
'context'
]
=
chain_output
context_params
=
OutLinePromptTemplate
.
from_template
(
template
=
chain_output
)
.
input_variables
if
context_params
:
for
context_param
in
context_params
:
if
context_param
not
in
inputs
:
inputs
[
context_param
]
=
'{'
+
context_param
+
'}'
prompt_inputs
=
{
k
:
inputs
[
k
]
for
k
in
prompt_template
.
input_variables
if
k
in
inputs
}
prompt_content
=
prompt_template
.
format
(
...
...
@@ -210,8 +215,16 @@ And answer according to the language of the user's question.
rest_tokens
=
llm_constant
.
max_context_token_length
[
memory
.
llm
.
model_name
]
\
-
memory
.
llm
.
max_tokens
-
curr_message_tokens
rest_tokens
=
max
(
rest_tokens
,
0
)
history_messages
=
cls
.
get_history_messages_from_memory
(
memory
,
rest_tokens
)
human_message_prompt
+=
"
\n\n
"
+
history_messages
histories
=
cls
.
get_history_messages_from_memory
(
memory
,
rest_tokens
)
# disable template string in query
histories_params
=
OutLinePromptTemplate
.
from_template
(
template
=
histories
)
.
input_variables
if
histories_params
:
for
histories_param
in
histories_params
:
if
histories_param
not
in
human_inputs
:
human_inputs
[
histories_param
]
=
'{'
+
histories_param
+
'}'
human_message_prompt
+=
"
\n\n
"
+
histories
human_message_prompt
+=
query_prompt
...
...
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