import { PromptVariable } from '@/types/app' export function replaceVarWithValues(str: string, promptVariables: PromptVariable[], inputs: Record) { return str.replace(/\{\{([^}]+)\}\}/g, (match, key) => { const name = inputs[key] if (name) return name const valueObj: PromptVariable | undefined = promptVariables.find(v => v.key === key) return valueObj ? `{{${valueObj.key}}}` : match }) }