Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.
Python ai-filmmakingai-videoai-video-generatorapple-siliconhailuoimage-to-videolip-synclocal-ailora-trainingltx-2ltx-2-5ltx-videomacosminimax-h3mlxmusic-generationoffline-aipinokiotext-to-videovideo-generation
fix(agent): handle reasoning models + Phosphene-branded avatar
mrbizarro0ce8493f8ae9
diff --git a/agent/engine.py b/agent/engine.pyindex 2bca730..cb5157c 100644--- a/agent/engine.py+++ b/agent/engine.py@@ -37,7 +37,12 @@ class EngineConfig:model: str = "mlx-community/gemma-3-12b-it-4bit"api_key: str = ""temperature: float = 0.4- max_tokens: int = 3072+ # 8192 was 3072 — reasoning-class models (Qwen 3.6, DeepSeek R1) put+ # their full chain-of-thought into the response, separately from the+ # final answer, and 3k tokens isn't enough room for both. Symptom on+ # the older budget: content="", finish_reason="length", and the agent+ # appears "stuck" because the runtime sees an empty assistant message.+ max_tokens: int = 8192# mlx-lm.server boot args — only used when kind == "phosphene_local".# `local_model_path` may be a Hugging Face id ("Qwen/Qwen3-30B-A3B-Instruct-4bit")# OR an absolute path to a local model dir (the bundled Gemma path).@@ -185,6 +190,32 @@ def chat(messages: list[dict], config: EngineConfig,content = msg.get("content") or ""finish = data["choices"][0].get("finish_reason") or "stop"usage = data.get("usage") or {}++ # Reasoning-model handling. mlx-lm.server (and similar) split a+ # thinking model's output into `message.reasoning` (chain-of-thought)+ # and `message.content` (final answer). When max_tokens is too small,+ # reasoning consumes the budget and content comes back empty with+ # finish_reason="length" — the agent gets nothing and the chat+ # appears "stuck". Two recovery paths:+ # 1. Empty content + non-empty reasoning + finish="length" → raise+ # a clear error so the user knows to bump max_tokens.+ # 2. Empty content + non-empty reasoning + finish="stop" → use+ # the reasoning as content. This is unusual (the model+ # decided to put its answer in the thinking block) but better+ # than silently dropping output.+ reasoning = msg.get("reasoning") or ""+ if not content and reasoning:+ if finish == "length":+ raise RuntimeError(+ "Reasoning model truncated mid-thought "+ f"({len(reasoning)} chars of reasoning, no answer). "+ f"Bump 'Max tokens' in agent settings — current is "+ f"{config.max_tokens}; try 12000+ for Qwen 3.6 / DeepSeek R1."+ )+ # No length issue but content is empty — fall back to reasoning+ # so SOMETHING surfaces in the chat.+ content = reasoning+return ChatResult(content=content, finish_reason=finish, usage=usage,model=data.get("model", config.model))diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.pyindex 916aa69..de5b6f7 100644--- a/mlx_ltx_panel.py+++ b/mlx_ltx_panel.py@@ -3443,7 +3443,7 @@ def _default_agent_engine_config() -> agent_engine.EngineConfig:local_model_path=str(GEMMA),api_key="",temperature=0.4,- max_tokens=3072,+ max_tokens=8192,)@@ -7843,10 +7843,22 @@ HTML = r"""<!doctype html>letter-spacing: 0.3px;user-select: none;}+ /* Phosphene-branded avatar — circular logo on a dark background.+ Replaces the prior orange "C" placeholder so the agent reads as+ Phosphene, not a generic chat bot. The logo is the same circular+ glyph used as the favicon and in the offline banner. */.agent-avatar.claude {- background: linear-gradient(135deg, #cc7a3a, #d18b4f);- color: white;- box-shadow: 0 0 0 1px rgba(204,122,58,0.3);+ background: radial-gradient(circle at 50% 50%, #1a0e2e 0%, #0a0518 70%);+ color: transparent;+ padding: 2px;+ box-shadow: 0 0 0 1px rgba(187, 89, 233, 0.25);+ overflow: hidden;+ }+ .agent-avatar.claude::before {+ content: '';+ display: block;+ width: 100%; height: 100%;+ background: url('/assets/favicon-64.png') center/contain no-repeat;}.agent-avatar.user {background: var(--panel-2);@@ -10693,7 +10705,7 @@ HTML = r"""<!doctype html></div><div class="field"><label>Max tokens</label>- <input type="number" id="agentMaxTokens" min="256" max="32768" step="256" value="3072">+ <input type="number" id="agentMaxTokens" min="256" max="32768" step="256" value="8192"></div></div>@@ -14685,14 +14697,17 @@ function renderMessage(m) {const av = document.createElement('div');av.className = `agent-avatar ${m.kind === 'user' ? 'user' : 'claude'}`;- av.textContent = m.kind === 'user' ? 'U' : 'C';+ // User shows initial "U"; assistant shows the circular Phosphene logo+ // via CSS background — leave textContent empty for assistant so the+ // ::before sprite is visible.+ av.textContent = m.kind === 'user' ? 'U' : '';const body = document.createElement('div');body.className = 'agent-msg-body';const name = document.createElement('div');name.className = 'agent-msg-name';- name.textContent = m.kind === 'user' ? 'You' : 'Claude';+ name.textContent = m.kind === 'user' ? 'You' : 'Phosphene';body.appendChild(name);@@ -15068,7 +15083,7 @@ function renderTypingRow(msg) {row.id = 'agentTypingRow';const av = document.createElement('div');av.className = 'agent-avatar claude';- av.textContent = 'C';+ av.textContent = ''; // CSS ::before paints the Phosphene logoconst bubble = document.createElement('div');bubble.className = 'agent-typing-bubble';bubble.innerHTML = `@@ -15565,7 +15580,7 @@ function openAgentSettings() {document.getElementById('agentAnthropicCustomModel').style.display = 'none';}document.getElementById('agentTemp').value = cfg.temperature ?? 0.4;- document.getElementById('agentMaxTokens').value = cfg.max_tokens ?? 3072;+ document.getElementById('agentMaxTokens').value = cfg.max_tokens ?? 8192;// Image-engine fieldsdocument.getElementById('agentImageKind').value = imgCfg.kind || 'mock';@@ -15809,7 +15824,7 @@ async function agentSaveSettings() {const payload = {kind,temperature: parseFloat(document.getElementById('agentTemp').value || '0.4'),- max_tokens: parseInt(document.getElementById('agentMaxTokens').value || '3072', 10),+ max_tokens: parseInt(document.getElementById('agentMaxTokens').value || '8192', 10),};if (kind === 'phosphene_local') {const sel = document.getElementById('agentLocalModel');