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
e8e8f9e9
Unverified
Commit
e8e8f9e9
authored
May 21, 2023
by
John Wang
Committed by
GitHub
May 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: move pre prompt to user massasge in chat mode (#126)
parent
18d1f6a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
completion.py
api/core/completion.py
+10
-8
No files found.
api/core/completion.py
View file @
e8e8f9e9
...
@@ -157,11 +157,6 @@ And answer according to the language of the user's question.
...
@@ -157,11 +157,6 @@ And answer according to the language of the user's question.
else
:
else
:
messages
:
List
[
BaseMessage
]
=
[]
messages
:
List
[
BaseMessage
]
=
[]
if
pre_prompt
:
# append pre prompt as system message
system_message
=
PromptBuilder
.
to_system_message
(
pre_prompt
,
inputs
)
messages
.
append
(
system_message
)
human_inputs
=
{
human_inputs
=
{
"query"
:
query
"query"
:
query
}
}
...
@@ -170,7 +165,7 @@ And answer according to the language of the user's question.
...
@@ -170,7 +165,7 @@ And answer according to the language of the user's question.
if
chain_output
:
if
chain_output
:
human_inputs
[
'context'
]
=
chain_output
human_inputs
[
'context'
]
=
chain_output
human_message_
prompt
=
"""Use the following CONTEXT as your learned knowledge.
human_message_
instruction
=
"""Use the following CONTEXT as your learned knowledge.
[CONTEXT]
[CONTEXT]
{context}
{context}
[END CONTEXT]
[END CONTEXT]
...
@@ -180,9 +175,16 @@ When answer to user:
...
@@ -180,9 +175,16 @@ When answer to user:
- If you don't know when you are not sure, ask for clarification.
- If you don't know when you are not sure, ask for clarification.
Avoid mentioning that you obtained the information from the context.
Avoid mentioning that you obtained the information from the context.
And answer according to the language of the user's question.
And answer according to the language of the user's question.
"""
if
pre_prompt
:
human_inputs
.
update
(
inputs
)
human_message_instruction
+=
pre_prompt
+
"
\n
"
Q:{query}
human_message_prompt
=
human_message_instruction
+
"Q:{query}
\n
A:"
A:"""
else
:
if
pre_prompt
:
human_inputs
.
update
(
inputs
)
human_message_prompt
=
pre_prompt
+
"
\n
"
+
human_message_prompt
# construct main prompt
# construct main prompt
human_message
=
PromptBuilder
.
to_human_message
(
human_message
=
PromptBuilder
.
to_human_message
(
...
...
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