fix: lint

pull/21451/head
crazywoola 11 months ago
parent 6541c4634e
commit cbe853fdab

@ -97,13 +97,6 @@ const Prompt: FC<ISimplePromptInput> = ({
}, },
}) })
} }
const promptVariablesObj = (() => {
const obj: Record<string, boolean> = {}
promptVariables.forEach((item) => {
obj[item.key] = true
})
return obj
})()
const [newPromptVariables, setNewPromptVariables] = React.useState<PromptVariable[]>(promptVariables) const [newPromptVariables, setNewPromptVariables] = React.useState<PromptVariable[]>(promptVariables)
const [newTemplates, setNewTemplates] = React.useState('') const [newTemplates, setNewTemplates] = React.useState('')
@ -111,11 +104,10 @@ const Prompt: FC<ISimplePromptInput> = ({
const handleChange = (newTemplates: string, keys: string[]) => { const handleChange = (newTemplates: string, keys: string[]) => {
// Filter out keys that are not properly defined (either not exist or exist but without valid name) // Filter out keys that are not properly defined (either not exist or exist but without valid name)
const newPromptVariables = keys.filter(key => { const newPromptVariables = keys.filter((key) => {
// Check if key exists in external data tools // Check if key exists in external data tools
if (externalDataToolsConfig.find((item: ExternalDataTool) => item.variable === key)) { if (externalDataToolsConfig.find((item: ExternalDataTool) => item.variable === key))
return false return false
}
// Check if key exists in prompt variables // Check if key exists in prompt variables
const existingVar = promptVariables.find((item: PromptVariable) => item.key === key) const existingVar = promptVariables.find((item: PromptVariable) => item.key === key)
@ -125,10 +117,7 @@ const Prompt: FC<ISimplePromptInput> = ({
} }
// Variable exists but check if it has valid name and key // Variable exists but check if it has valid name and key
if (!existingVar.name || !existingVar.name.trim() || !existingVar.key || !existingVar.key.trim()) { return !existingVar.name || !existingVar.name.trim() || !existingVar.key || !existingVar.key.trim()
// Variable exists but doesn't have valid name or key
return true
}
return false return false
}).map(key => getNewVar(key, '')) }).map(key => getNewVar(key, ''))

Loading…
Cancel
Save