feat: LLM auto-fallback + codegen pack + OCR pack
LLM auto-fallback (jarvis-app/src/app.rs + jarvis-core/src/config.rs):
- When neither intent classifier nor levenshtein finds a command match,
route the utterance straight to the LLM instead of just playing the
"not found" sound. Triggers ("скажи X", "answer Y") still work and
take precedence — they short-circuit before command lookup.
- Two new config knobs:
LLM_AUTO_FALLBACK = true — master toggle
LLM_AUTO_FALLBACK_MIN_CHARS = 4 — suppress for very short utterances
so background noise doesn't burn
Groq quota
- Requires GROQ_TOKEN; if absent, behaviour is unchanged (play_not_found).
codegen/ command pack:
- Phrases: "напиши код X", "сгенерируй скрипт Y", "write code Z", etc.
- Strips the trigger from the recognized phrase, sends what remains to
Groq with a strict system prompt ("return ONLY code, no fences, no
commentary") at temperature 0.2.
- Parses the JSON content, unescapes \n / \" / \\ / \t, strips any
remaining ```lang ... ``` fences, drops the result into the clipboard
via jarvis.system.clipboard.set.
- Notifies a 120-char preview + plays ok-sound. Works for any language
the model handles (Python by default if unspecified).
- GROQ_TOKEN / GROQ_MODEL / GROQ_BASE_URL read from env at call time —
same envvars the voice-loop fallback already uses.
ocr/ command pack:
- Phrases: "прочитай экран", "что на экране", "read screen", etc.
- Captures the primary screen via System.Windows.Forms + System.Drawing
to a temp PNG, then shells to tesseract.exe (-l rus+eng for ru/ua,
-l eng for en).
- Resolves Tesseract by PATH first, then C:\Program Files\Tesseract-OCR
and the x86 install dir; if none works the user gets a friendly
"winget install UB-Mannheim.TesseractOCR" hint in a notification.
- Recognized text goes to clipboard + a 200-char preview notification.
All three features are portable (env-var resolution, no hardcoded user
paths). Command-pack total is now 11. cargo test -p jarvis-core --lib
commands::tests passes 3/3.
This commit is contained in:
parent
429113175a
commit
69a38b0d89
6 changed files with 255 additions and 5 deletions
27
resources/commands/codegen/command.toml
Normal file
27
resources/commands/codegen/command.toml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[[commands]]
|
||||
id = "codegen_clipboard"
|
||||
type = "lua"
|
||||
script = "codegen.lua"
|
||||
sandbox = "full"
|
||||
timeout = 30000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"напиши код",
|
||||
"сгенерируй код",
|
||||
"набросай код",
|
||||
"сделай скрипт",
|
||||
"напиши скрипт",
|
||||
"сгенерируй скрипт",
|
||||
]
|
||||
en = [
|
||||
"write code",
|
||||
"generate code",
|
||||
"make script",
|
||||
"write script",
|
||||
]
|
||||
ua = [
|
||||
"напиши код",
|
||||
"згенеруй код",
|
||||
"зроби скрипт",
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue