Repository navigation
Rework the examples around a fast check and a small model parse - #22
Merged
Merged
Conversation
Each example now checks for its word first and returns the text untouched when it is absent, so the model is only asked when a dictation is meant for that file. - translate_ja_es.py replaces translate.py: the request can open or end the sentence, and the model decides whether a mention of the language is a request. - web_search.py replaces ask.py: say "search" and the model picks out the browser and the query. - mac_commands.py replaces voice_commands.py: the model classifies free phrasing into a fixed list of commands, with light mode and Night Shift added. - terminal.py takes four opening words, keeps no state between hooks and uses a 7B coder model.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The examples are reworked so that each one makes a fast check for its word, and only then asks a small local model to work out what was meant. A dictation without the word is returned untouched and costs no model call.
translate_ja_es.pytranslate.pyweb_search.pyask.pymac_commands.pyvoice_commands.pyterminal.pytalk_like_a_pirate.pyandhud.pyare unchanged.How each one works
{"language": ...}ornull, which is how "The menu was written in Japanese." is left alone. The code removes the request from whichever end of the sentence it is on. The old version only accepted the request at the front and was limited to an exact "in " opening.{"browser", "query"}, so the browser can be named anywhere in the sentence. If the reply does not parse, the whole sentence is searched in the default browser.COMMANDSdict,open <app>, ornone.nonehands the text back as an ordinary dictation. New commands: light mode, Night Shift on and off. "dark mode" now sets dark instead of toggling.on_cleanedhook and no module state. It usesmlx-community/Qwen2.5-Coder-7B-Instruct-4bitinstead of the 4B model, and strips backticks the model sometimes wraps the command in.Every hook now returns a string on every path (
return tto change nothing) instead ofNone.Things a reviewer should know
web_search.pymaps "Firefox" to Waterfox. That matches the author's setup. Anyone without Waterfox gets an error when they name Firefox, until they editBROWSERS. The examples README says so.osascript. It works on macOS 26.4 and may break in a later release.web_search.pyacts inon_transcribed, so "Terminal, search for files named foo" opens a browser beforeterminal.pysees it.web_search.pyusesexcept A, B:without parentheses, asruff formatwrites it for this project.terminal.pydownloads a second model of about 4 GB the first time.Testing
Each file was run against the real models on sample dictations, with browser launches and Mac commands replaced by prints:
renameis not installed by default, and anlsof | awkpipeline passes the header line tokill).Night Shift on and off was run for real. The other Mac commands and the browser launches were not run for real by these checks. There are no automated tests for the examples, and nothing under
sidecar/changes.ruff checkandruff format --checkpass onexamples/.The two README edits bring the examples table and the one-line summary in the root README in line with the new files.