feat: Ollama LLM backend + 5 utility packs (daily briefing, pomodoro, currency convert, stocks, habits, translate clipboard)
Local-LLM support so J.A.R.V.I.S. works offline without GROQ_TOKEN.
LLM multi-backend (crates/jarvis-core/src/llm/client.rs)
- LlmBackend enum {Groq, Ollama}. Both use OpenAI-compatible /v1/chat/completions
(Ollama exposes one natively at :11434/v1).
- LlmClient::from_env() now dispatches on JARVIS_LLM=groq|ollama. Auto-detect:
Groq if GROQ_TOKEN set, else Ollama.
- New helpers: LlmClient::groq() (was: from_env), LlmClient::ollama().
- Reqwest client now has a 60s timeout (was: unbounded — Groq freezes could hang).
- api_key skipped when empty (Ollama doesn't need auth).
- Defaults: OLLAMA_BASE_URL=http://localhost:11434/v1, OLLAMA_MODEL=qwen2.5:3b.
Override via OLLAMA_BASE_URL / OLLAMA_MODEL env.
- llm_fallback + llm_router log the active backend on init.
- Tests: 32/32 pass. Renamed `from_env_fails` → `groq_fails_when_token_missing`,
added `ollama_works_without_token`.
Daily briefing pack (resources/commands/daily_briefing/, 3 commands)
- setup.lua: "настрой утренний брифинг на 9:00" → adds a daily scheduled task
that runs now.lua via the scheduler's Lua-action support.
- now.lua: greeting + time + active profile + scheduled task count + memory recap
+ LLM motivational nudge. Voice-triggered ("утренний брифинг") works the same.
- off.lua: removes the scheduled task.
Pomodoro pack (resources/commands/pomodoro/, 2 commands)
- start.lua / stop.lua + tick.lua (re-scheduled by itself). State stored in
jarvis.state — phase alternates work (25 min) / break (5 min) until stop.
Currency conversion (resources/commands/currency/convert.lua)
- "сколько будет 1000 долларов в рублях" — fetches CBR daily rates from
cbr-xml-daily.ru, normalises by Nominal, prints both directions.
- Recognises USD/EUR/CNY/GBP/JPY/RUB by substring. Pluralises russian units.
Stocks pack (resources/commands/stocks/, 1 command)
- "сколько Сбер" → MOEX ISS /iss/engines/stock/markets/shares/securities/<TKR>.
- Mapping of 22 popular Russian tickers to common names (Сбер→SBER, Газпром→GAZP,
Лукойл→LKOH, Яндекс→YDEX, Т-банк→T, etc).
- Picks TQBR (main board) row, reports LAST + LASTTOPREVPRICE%.
Habit nudges (resources/commands/habit_nudge/, 4 commands)
- "напоминай мне пить воду" → every 2 hours
- "напоминай мне размяться" → every 50 minutes
- "напоминай отдыхать глазам" → every 20 minutes (20-20-20 rule)
- "отключи все привычки" → stops all three by id.
Translate clipboard (resources/commands/translate/clipboard.lua)
- "переведи буфер на английский" → grabs clipboard, sends to LLM, speaks first
sentence, replaces clipboard with full translation, fires notification.
Build: cargo build --release -p jarvis-app -p jarvis-gui both green. 32/32 tests.
To use Ollama:
1. Install + run Ollama (https://ollama.com).
2. `ollama pull qwen2.5:3b` (or any chat model).
3. Optional: `set JARVIS_LLM=ollama` (auto-picked if GROQ_TOKEN unset).
This commit is contained in:
parent
12b1ed4ccb
commit
45243c3e3c
22 changed files with 895 additions and 16 deletions
69
resources/commands/habit_nudge/command.toml
Normal file
69
resources/commands/habit_nudge/command.toml
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# Habit nudges — convenient wrappers for popular recurring reminders.
|
||||
|
||||
[[commands]]
|
||||
id = "habit.water"
|
||||
type = "lua"
|
||||
script = "water.lua"
|
||||
sandbox = "standard"
|
||||
timeout = 3000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"напоминай мне пить воду",
|
||||
"напоминай попить воду",
|
||||
"включи напоминание про воду",
|
||||
]
|
||||
en = ["remind me to drink water", "water reminder"]
|
||||
ua = ["нагадуй мені пити воду"]
|
||||
|
||||
|
||||
[[commands]]
|
||||
id = "habit.stretch"
|
||||
type = "lua"
|
||||
script = "stretch.lua"
|
||||
sandbox = "standard"
|
||||
timeout = 3000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"напоминай мне размяться",
|
||||
"напоминай делать зарядку",
|
||||
"включи напоминание про разминку",
|
||||
"напоминай вставать",
|
||||
]
|
||||
en = ["remind me to stretch", "stretch reminder"]
|
||||
ua = ["нагадуй мені розім'ятися"]
|
||||
|
||||
|
||||
[[commands]]
|
||||
id = "habit.eyes"
|
||||
type = "lua"
|
||||
script = "eyes.lua"
|
||||
sandbox = "standard"
|
||||
timeout = 3000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"напоминай отдыхать глазам",
|
||||
"напоминай про глаза",
|
||||
"20 20 20",
|
||||
]
|
||||
en = ["remind me to rest eyes", "eye reminder"]
|
||||
ua = ["нагадуй про очі"]
|
||||
|
||||
|
||||
[[commands]]
|
||||
id = "habit.stop_all"
|
||||
type = "lua"
|
||||
script = "stop_all.lua"
|
||||
sandbox = "minimal"
|
||||
timeout = 3000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"отключи все привычки",
|
||||
"хватит напоминать про привычки",
|
||||
"выключи все напоминалки",
|
||||
]
|
||||
en = ["stop all habits", "disable habit reminders"]
|
||||
ua = ["вимкни всі звички"]
|
||||
18
resources/commands/habit_nudge/eyes.lua
Normal file
18
resources/commands/habit_nudge/eyes.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-- 20-20-20 rule: every 20 min look 20ft away for 20s.
|
||||
jarvis.scheduler.remove("habit_eyes")
|
||||
local ok, err = pcall(function()
|
||||
jarvis.scheduler.add({
|
||||
id = "habit_eyes",
|
||||
name = "20-20-20 eye rest",
|
||||
schedule = "every 20 minutes",
|
||||
action = { type = "speak", text = "Отвлекитесь от экрана на двадцать секунд." }
|
||||
})
|
||||
end)
|
||||
if not ok then
|
||||
jarvis.speak("Не получилось.")
|
||||
jarvis.audio.play_error()
|
||||
return { chain = false }
|
||||
end
|
||||
jarvis.speak("Включил правило двадцать двадцать двадцать.")
|
||||
jarvis.audio.play_ok()
|
||||
return { chain = false }
|
||||
14
resources/commands/habit_nudge/stop_all.lua
Normal file
14
resources/commands/habit_nudge/stop_all.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local removed = 0
|
||||
for _, id in ipairs({ "habit_water", "habit_stretch", "habit_eyes" }) do
|
||||
if jarvis.scheduler.remove(id) then
|
||||
removed = removed + 1
|
||||
end
|
||||
end
|
||||
if removed > 0 then
|
||||
jarvis.speak("Отключил привычек: " .. removed .. ".")
|
||||
jarvis.audio.play_ok()
|
||||
else
|
||||
jarvis.speak("Привычки и так не запущены.")
|
||||
jarvis.audio.play_not_found()
|
||||
end
|
||||
return { chain = false }
|
||||
17
resources/commands/habit_nudge/stretch.lua
Normal file
17
resources/commands/habit_nudge/stretch.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
jarvis.scheduler.remove("habit_stretch")
|
||||
local ok, err = pcall(function()
|
||||
jarvis.scheduler.add({
|
||||
id = "habit_stretch",
|
||||
name = "Stretch break",
|
||||
schedule = "every 50 minutes",
|
||||
action = { type = "speak", text = "Время размяться. Встаньте, пройдитесь." }
|
||||
})
|
||||
end)
|
||||
if not ok then
|
||||
jarvis.speak("Не получилось.")
|
||||
jarvis.audio.play_error()
|
||||
return { chain = false }
|
||||
end
|
||||
jarvis.speak("Каждые 50 минут буду напоминать размяться.")
|
||||
jarvis.audio.play_ok()
|
||||
return { chain = false }
|
||||
17
resources/commands/habit_nudge/water.lua
Normal file
17
resources/commands/habit_nudge/water.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
jarvis.scheduler.remove("habit_water")
|
||||
local ok, err = pcall(function()
|
||||
jarvis.scheduler.add({
|
||||
id = "habit_water",
|
||||
name = "Drink water",
|
||||
schedule = "every 2 hours",
|
||||
action = { type = "speak", text = "Попей воды." }
|
||||
})
|
||||
end)
|
||||
if not ok then
|
||||
jarvis.speak("Не получилось.")
|
||||
jarvis.audio.play_error()
|
||||
return { chain = false }
|
||||
end
|
||||
jarvis.speak("Каждые 2 часа буду напоминать пить воду.")
|
||||
jarvis.audio.play_ok()
|
||||
return { chain = false }
|
||||
Loading…
Add table
Add a link
Reference in a new issue