Add OpenCode / Ollama LLM integration with gemma4:31b default

This commit is contained in:
Adolfo Reyna
2026-08-07 18:57:11 -04:00
parent 1a8a93695b
commit 4773b93779
4 changed files with 254 additions and 7 deletions
+29 -4
View File
@@ -153,14 +153,23 @@ def parse_args() -> argparse.Namespace:
)
parser.add_argument(
"--llm-engine",
choices=["apple", "macos", "claude"],
default="apple",
help="LLM engine to use: apple/macos for native on-device macOS LLM, claude for Claude Code.",
choices=["ollama", "opencode", "apple", "macos", "claude"],
default="ollama",
help="LLM engine to use: ollama/opencode for Ollama/Cloud models, apple/macos for local MLX, claude for Claude Code.",
)
parser.add_argument(
"--ollama-model",
default="gemma4:31b",
help="Ollama / OpenCode model name (default gemma4:31b).",
)
parser.add_argument(
"--ollama-host",
help="Ollama API host URL (defaults to OLLAMA_HOST or http://localhost:11434).",
)
parser.add_argument(
"--mlx-model",
default="mlx-community/Qwen2.5-7B-Instruct-4bit",
help="MLX model repo or path for local macOS execution (e.g. mlx-community/Qwen2.5-7B-Instruct-4bit).",
help="MLX model repo or path for local macOS execution.",
)
parser.add_argument(
"--claude-model",
@@ -488,6 +497,22 @@ def build_claude_options(args: argparse.Namespace, vocabulary=None, brain=None)
def build_llm(args: argparse.Namespace, vocabulary=None, brain=None, observer=None):
if args.llm_engine in ("ollama", "opencode"):
from ollama_llm import OllamaLLM, probe_ollama, get_default_ollama_host
host = args.ollama_host or get_default_ollama_host()
logger.info(f"LLM: Ollama / OpenCode ({args.ollama_model} @ {host})")
personality = read_personality(args.cwd) or "You are a helpful voice assistant."
system_prompt = personality + "\n\n" + VOICE_STYLE
if brain and (memory := brain.prompt_block()):
system_prompt += "\n\n" + memory
return OllamaLLM(
model=args.ollama_model,
host=host,
system_prompt=system_prompt,
observer=observer,
)
if args.llm_engine in ("apple", "macos"):
from apple_llm import MacOSLLM, probe_apple_llm