@@ -10,6 +10,23 @@ object CommandParser {
1010
1111 // Regex patterns for different command formats
1212
13+ // Model selection patterns - for switching between high and low reasoning models
14+ private val MODEL_SELECTION_PATTERNS = listOf (
15+ // High reasoning model patterns
16+ Regex (" (?i)\\ bhighReasoningModel\\ (\\ )" ),
17+ Regex (" (?i)\\ buseHighReasoningModel\\ (\\ )" ),
18+ Regex (" (?i)\\ bswitchToHighReasoningModel\\ (\\ )" ),
19+ Regex (" (?i)\\ b(?:use|switch to|enable|activate|verwende|wechsle zu|aktiviere) (?:the )?(?:high|advanced|better|improved|höhere|verbesserte|bessere) (?:reasoning|thinking|intelligence|denk|intelligenz) model\\ b" ),
20+ Regex (" (?i)\\ b(?:use|switch to|enable|activate|verwende|wechsle zu|aktiviere) (?:the )?gemini(?:\\ -|\\ s)?2\\ .5(?:\\ -|\\ s)?pro\\ b" ),
21+
22+ // Low reasoning model patterns
23+ Regex (" (?i)\\ blowReasoningModel\\ (\\ )" ),
24+ Regex (" (?i)\\ buseLowReasoningModel\\ (\\ )" ),
25+ Regex (" (?i)\\ bswitchToLowReasoningModel\\ (\\ )" ),
26+ Regex (" (?i)\\ b(?:use|switch to|enable|activate|verwende|wechsle zu|aktiviere) (?:the )?(?:low|basic|simple|standard|niedrige|einfache|standard) (?:reasoning|thinking|intelligence|denk|intelligenz) model\\ b" ),
27+ Regex (" (?i)\\ b(?:use|switch to|enable|activate|verwende|wechsle zu|aktiviere) (?:the )?gemini(?:\\ -|\\ s)?2\\ .0(?:\\ -|\\ s)?flash\\ b" )
28+ )
29+
1330 // Write text patterns - for writing text into focused text fields
1431 private val WRITE_TEXT_PATTERNS = listOf (
1532 // Function-like patterns
@@ -239,6 +256,9 @@ object CommandParser {
239256 * Process text to find commands
240257 */
241258 private fun processText (text : String , commands : MutableList <Command >) {
259+ // Look for model selection commands
260+ findModelSelectionCommands(text, commands)
261+
242262 // Look for write text commands
243263 findWriteTextCommands(text, commands)
244264
@@ -276,6 +296,39 @@ object CommandParser {
276296 findOpenAppCommands(text, commands)
277297 }
278298
299+ /* *
300+ * Find model selection commands in the text
301+ */
302+ private fun findModelSelectionCommands (text : String , commands : MutableList <Command >) {
303+ // First check for high reasoning model commands
304+ for (i in 0 until 5 ) { // First 5 patterns are for high reasoning model
305+ val pattern = MODEL_SELECTION_PATTERNS [i]
306+ if (pattern.containsMatchIn(text)) {
307+ // Check if this command is already in the list (avoid duplicates)
308+ if (! commands.any { it is Command .UseHighReasoningModel }) {
309+ Log .d(TAG , " Found high reasoning model command with pattern ${pattern.pattern} " )
310+ commands.add(Command .UseHighReasoningModel )
311+ // Only add one high reasoning model command even if multiple matches are found
312+ break
313+ }
314+ }
315+ }
316+
317+ // Then check for low reasoning model commands
318+ for (i in 5 until MODEL_SELECTION_PATTERNS .size) { // Remaining patterns are for low reasoning model
319+ val pattern = MODEL_SELECTION_PATTERNS [i]
320+ if (pattern.containsMatchIn(text)) {
321+ // Check if this command is already in the list (avoid duplicates)
322+ if (! commands.any { it is Command .UseLowReasoningModel }) {
323+ Log .d(TAG , " Found low reasoning model command with pattern ${pattern.pattern} " )
324+ commands.add(Command .UseLowReasoningModel )
325+ // Only add one low reasoning model command even if multiple matches are found
326+ break
327+ }
328+ }
329+ }
330+ }
331+
279332 /* *
280333 * Find write text commands in the text
281334 */
@@ -743,4 +796,14 @@ sealed class Command {
743796 * Command to write text into the currently focused text field
744797 */
745798 data class WriteText (val text : String ) : Command()
799+
800+ /* *
801+ * Command to switch to high reasoning model (gemini-2.5-pro-preview-03-25)
802+ */
803+ object UseHighReasoningModel : Command()
804+
805+ /* *
806+ * Command to switch to low reasoning model (gemini-2.0-flash-lite)
807+ */
808+ object UseLowReasoningModel : Command()
746809}
0 commit comments