Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: extra input for opening statement was not suitable for prompt (#143)

John Wang54a6571462cb
diff --git a/api/core/completion.py b/api/core/completion.py
index d05d8417da8..8e79e03a933 100644
--- a/api/core/completion.py
+++ b/api/core/completion.py
@@ -177,13 +177,21 @@ Avoid mentioning that you obtained the information from the context.
And answer according to the language of the user's question.
"""
if pre_prompt:
- human_inputs.update(inputs)
+ extra_inputs = {k: inputs[k] for k in
+ OutLinePromptTemplate.from_template(template=pre_prompt).input_variables
+ if k in inputs}
+ if extra_inputs:
+ human_inputs.update(extra_inputs)
human_message_instruction += pre_prompt + "\n"
human_message_prompt = human_message_instruction + "Q:{query}\nA:"
else:
if pre_prompt:
- human_inputs.update(inputs)
+ extra_inputs = {k: inputs[k] for k in
+ OutLinePromptTemplate.from_template(template=pre_prompt).input_variables
+ if k in inputs}
+ if extra_inputs:
+ human_inputs.update(extra_inputs)
human_message_prompt = pre_prompt + "\n" + human_message_prompt
# construct main prompt