Add files via upload

This commit is contained in:
FatihMakes authored and GitHub committed 2026-06-07 17:03:02 +03:00
1 parent 6699c074ac
commit 5d8d214e9b
5 files changed
+117 -45

No files matched your search

+5 -4
View File
@@ -212,7 +212,7 @@ def call_llm(
"model": model,
"messages": messages,
"stream": False,
"max_tokens": 300,
"max_tokens": 150,
}
if tools:
payload["tools"] = tools
@@ -252,7 +252,7 @@ def call_llm(
"messages": messages,
"stream": False,
"keep_alive": -1,
"options": {"num_predict": 300, "num_gpu": 99},
"options": {"num_predict": 150, "num_gpu": 99},
}
if tools:
payload["tools"] = tools
@@ -353,7 +353,7 @@ def _stream_openai(
"model": model,
"messages": messages,
"stream": True,
"max_tokens": 300,
"max_tokens": 150,
}
if tools:
payload["tools"] = tools
@@ -479,8 +479,9 @@ def call_llm_stream(
"messages": messages,
"stream": True,
"keep_alive": -1,
# 150 tokens ≈ 100 words ≈ 3-4 sentences — enough for any voice reply.
# num_gpu:99 pushes all layers to GPU; num_thread removed (Ollama auto-tunes).
"options": {"num_predict": 300, "num_gpu": 99},
"options": {"num_predict": 150, "num_gpu": 99},
}
if tools:
payload["tools"] = tools
+6 -1
View File
@@ -12,7 +12,12 @@ EXECUTION RULES:
Action Flow: Call the tool immediately. For slow tools (search, vision), say ONE short sentence first.
Vision (screen_process): Say one curious sentence, then call the tool — total silence after.
One-Call Policy: Never guess. Call tools exactly once. No retries.
Briefing: 1 short sentence max for confirmations/acknowledgments. 1-2 sentences for results. Never add "Is there anything else?" or filler questions.
Briefing: HARD LIMIT — 3 SHORT sentences maximum for ANY response. No exceptions.
• Confirmations / acks: 1 sentence only.
• Answers / results: 2-3 short sentences max.
• NEVER ask follow-up questions ("Would you like...?", "Is there anything else?").
• NEVER pad with sympathy openers or filler phrases ("Of course!", "Great question!").
• If you cannot fit the answer in 3 sentences, give the most important part only.
Exit: Only call shutdown_jarvis if session termination is explicit.
Response time: Respond as fast as you can.
Always respond in the language that user is speaking.
+16 -1
View File
@@ -12,6 +12,7 @@ class WhisperSTT:
"""Offline transcription using faster-whisper."""
def __init__(self, model_name: str = "base", language: str | None = None):
import os
from faster_whisper import WhisperModel
print(f"[STT] Loading Whisper '{model_name}'…")
try:
@@ -20,7 +21,21 @@ class WhisperSTT:
compute = "float16" if device == "cuda" else "int8"
except Exception:
device, compute = "cpu", "int8"
self._model = WhisperModel(model_name, device=device, compute_type=compute)
try:
self._model = WhisperModel(model_name, device=device, compute_type=compute)
except Exception as _first_err:
# Offline flag set but model not cached yet → download once, then offline forever
_e = str(_first_err).lower()
if any(k in _e for k in ("offline", "not found", "cache", "localentry", "does not exist")):
print(f"[STT] '{model_name}' not cached — downloading (internet required for first run)…")
os.environ.pop("HF_HUB_OFFLINE", None)
os.environ.pop("TRANSFORMERS_OFFLINE", None)
os.environ.pop("HF_DATASETS_OFFLINE", None)
self._model = WhisperModel(model_name, device=device, compute_type=compute)
else:
raise
self._language = None if (not language or language.strip().lower() == "auto") else language.strip().lower()
print(f"[STT] Whisper '{model_name}' ready ({device})")
+18 -4
View File
@@ -264,11 +264,25 @@ class KokoroTTSEngine:
KPipeline = _import_kokoro_pipeline()
def _create_pipeline():
try:
return KPipeline(lang_code=lang, device=device)
except TypeError:
return KPipeline(lang_code=lang) # older build — no device param
try:
self._pipeline = KPipeline(lang_code=lang, device=device)
except TypeError:
# Older Kokoro build — no device parameter
self._pipeline = KPipeline(lang_code=lang)
self._pipeline = _create_pipeline()
except Exception as _first_err:
# Offline flag set but model not cached yet → download once
_e = str(_first_err).lower()
if any(k in _e for k in ("offline", "not found", "cache", "localentry", "does not exist")):
print("[TTS] Kokoro model not cached — downloading (internet required for first run)…")
os.environ.pop("HF_HUB_OFFLINE", None)
os.environ.pop("TRANSFORMERS_OFFLINE", None)
os.environ.pop("HF_DATASETS_OFFLINE", None)
self._pipeline = _create_pipeline()
else:
raise
print("[TTS] Kokoro compiling (first-time only)…")
# Warmup: compiles PyTorch JIT graph so first real speak() call is instant.