()
| 138 | const proxyMode = !apiKey && !!ultraplinianApiUrl && !!ultraplinianApiKey |
| 139 | |
| 140 | const handleSubmit = async () => { |
| 141 | if (!input.trim() || !currentConversationId || isStreaming) return |
| 142 | if (!apiKey && !proxyMode) return |
| 143 | |
| 144 | const originalMessage = input.trim() |
| 145 | setInput('') |
| 146 | setIsStreaming(true) |
| 147 | incrementPromptsTried() |
| 148 | |
| 149 | // Apply parseltongue obfuscation if enabled |
| 150 | const parseltongueResult = applyParseltongue(originalMessage, parseltongueConfig) |
| 151 | const userMessage = parseltongueResult.transformedText |
| 152 | |
| 153 | |
| 154 | // Add user message (show original to user, send transformed to API) |
| 155 | addMessage(currentConversationId, { |
| 156 | role: 'user', |
| 157 | content: originalMessage // Show original message in UI |
| 158 | }) |
| 159 | |
| 160 | // Get persona and model |
| 161 | const persona = personas.find(p => p.id === currentConversation?.persona) || personas[0] |
| 162 | const model = currentConversation?.model || 'anthropic/claude-3-opus' |
| 163 | |
| 164 | // Build memory context if enabled |
| 165 | const activeMemories = memoriesEnabled ? memories.filter(m => m.active) : [] |
| 166 | let memoryContext = '' |
| 167 | if (activeMemories.length > 0) { |
| 168 | const facts = activeMemories.filter(m => m.type === 'fact') |
| 169 | const preferences = activeMemories.filter(m => m.type === 'preference') |
| 170 | const instructions = activeMemories.filter(m => m.type === 'instruction') |
| 171 | |
| 172 | memoryContext = '\n\n<user_memory>\n' |
| 173 | if (facts.length > 0) { |
| 174 | memoryContext += '## About the User\n' |
| 175 | facts.forEach(f => { memoryContext += `- ${f.content}\n` }) |
| 176 | } |
| 177 | if (preferences.length > 0) { |
| 178 | memoryContext += '\n## User Preferences\n' |
| 179 | preferences.forEach(p => { memoryContext += `- ${p.content}\n` }) |
| 180 | } |
| 181 | if (instructions.length > 0) { |
| 182 | memoryContext += '\n## Always Follow\n' |
| 183 | instructions.forEach(i => { memoryContext += `- ${i.content}\n` }) |
| 184 | } |
| 185 | memoryContext += '</user_memory>\n' |
| 186 | } |
| 187 | |
| 188 | // Build system prompt with GODMODE prompt + memory |
| 189 | const basePrompt = useCustomSystemPrompt ? customSystemPrompt : (persona.systemPrompt || persona.coreDirective || '') |
| 190 | const systemPrompt = basePrompt + memoryContext |
| 191 | |
| 192 | // Build messages array |
| 193 | const messages = [ |
| 194 | // System prompt from persona + memory |
| 195 | ...(systemPrompt ? [{ role: 'system' as const, content: systemPrompt }] : []), |
| 196 | // Conversation history |
| 197 | ...((currentConversation?.messages || []).map(m => ({ |
no test coverage detected