mirror of
https://github.com/langgenius/dify.git
synced 2026-03-10 09:56:13 +08:00
refactor: Refactor agent context insertion to use regex
This commit is contained in:
@ -500,13 +500,8 @@ const MixedVariableTextInput = ({
|
||||
if (!onChange)
|
||||
return
|
||||
|
||||
const valueWithoutTrigger = (() => {
|
||||
const lineStart = value.lastIndexOf('\n') + 1
|
||||
const triggerIndex = value.lastIndexOf('@')
|
||||
if (triggerIndex < lineStart)
|
||||
return value
|
||||
return value.slice(0, triggerIndex)
|
||||
})()
|
||||
// compute words after the latest '@' and delete them
|
||||
const valueWithoutTrigger = value.replace(/@[^@\n]*$/, '')
|
||||
const newValue = `{{@${agent.id}.context@}}${valueWithoutTrigger}`
|
||||
|
||||
if (toolNodeId && paramKey) {
|
||||
|
||||
Reference in New Issue
Block a user