Browse Source

enh/refac: show input modal by default for prompt variables

Timothy Jaeryang Baek 3 months ago
parent
commit
44754e4c4a
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/lib/components/chat/MessageInput.svelte

+ 12 - 0
src/lib/components/chat/MessageInput.svelte

@@ -120,6 +120,8 @@
 
 	const extractInputVariables = (text: string): Record<string, any> => {
 		const regex = /{{\s*([^|}\s]+)\s*\|\s*([^}]+)\s*}}/g;
+		const regularRegex = /{{\s*([^|}\s]+)\s*}}/g;
+
 		const variables: Record<string, any> = {};
 		let match;
 
@@ -130,6 +132,16 @@
 			variables[varName] = parseVariableDefinition(definition);
 		}
 
+		// Then, extract regular variables (without pipe) - only if not already processed
+		while ((match = regularRegex.exec(text)) !== null) {
+			const varName = match[1].trim();
+
+			// Only add if not already processed as custom variable
+			if (!variables.hasOwnProperty(varName)) {
+				variables[varName] = { type: 'text' }; // Default type for regular variables
+			}
+		}
+
 		return variables;
 	};