feat: query prompt template support in chatflow (#3791)
Co-authored-by: Joel <iamjoel007@gmail.com>
This commit is contained in:
parent
80b9507e7a
commit
12435774ca
12 changed files with 113 additions and 18 deletions
|
|
@ -146,6 +146,7 @@ const Editor: FC<Props> = ({
|
|||
<PromptEditor
|
||||
instanceId={instanceId}
|
||||
compact
|
||||
className='min-h-[56px]'
|
||||
style={isExpand ? { height: editorExpandHeight - 5 } : {}}
|
||||
value={value}
|
||||
contextBlock={{
|
||||
|
|
|
|||
|
|
@ -272,10 +272,12 @@ export const getNodeUsedVars = (node: Node): ValueSelector[] => {
|
|||
const payload = (data as LLMNodeType)
|
||||
const isChatModel = payload.model?.mode === 'chat'
|
||||
let prompts: string[] = []
|
||||
if (isChatModel)
|
||||
if (isChatModel) {
|
||||
prompts = (payload.prompt_template as PromptItem[])?.map(p => p.text) || []
|
||||
else
|
||||
prompts = [(payload.prompt_template as PromptItem).text]
|
||||
if (payload.memory?.query_prompt_template)
|
||||
prompts.push(payload.memory.query_prompt_template)
|
||||
}
|
||||
else { prompts = [(payload.prompt_template as PromptItem).text] }
|
||||
|
||||
const inputVars: ValueSelector[] = matchNotSystemVars(prompts)
|
||||
const contextVar = (data as LLMNodeType).context?.variable_selector ? [(data as LLMNodeType).context?.variable_selector] : []
|
||||
|
|
@ -375,6 +377,8 @@ export const updateNodeVars = (oldNode: Node, oldVarSelector: ValueSelector, new
|
|||
text: replaceOldVarInText(prompt.text, oldVarSelector, newVarSelector),
|
||||
}
|
||||
})
|
||||
if (payload.memory?.query_prompt_template)
|
||||
payload.memory.query_prompt_template = replaceOldVarInText(payload.memory.query_prompt_template, oldVarSelector, newVarSelector)
|
||||
}
|
||||
else {
|
||||
payload.prompt_template = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue