Standardized models: MacBook=qwen3.5:4b-mlx, GamingPC=ornith:latest across all configs
This commit is contained in:
@@ -169,7 +169,7 @@ def _call_deepseek(prompt: str, model: str = "deepseek-chat", system: str = "",
|
|||||||
raise RuntimeError(f"DeepSeek API error {r.status_code}: {r.text[:200]}")
|
raise RuntimeError(f"DeepSeek API error {r.status_code}: {r.text[:200]}")
|
||||||
|
|
||||||
|
|
||||||
def llm_chat(prompt: str, model: str = "qwen3.5:4b", host: str = OLLAMA_MACBOOK,
|
def llm_chat(prompt: str, model: str = "qwen3.5:4b-mlx", host: str = OLLAMA_MACBOOK,
|
||||||
system: str = "", temperature: float = 0.7, max_tokens: int = 4096,
|
system: str = "", temperature: float = 0.7, max_tokens: int = 4096,
|
||||||
retries: int = 3) -> str:
|
retries: int = 3) -> str:
|
||||||
"""Call LLM with Ollama → DeepSeek fallback, with retries."""
|
"""Call LLM with Ollama → DeepSeek fallback, with retries."""
|
||||||
@@ -212,7 +212,7 @@ def llm_chat(prompt: str, model: str = "qwen3.5:4b", host: str = OLLAMA_MACBOOK,
|
|||||||
raise RuntimeError(f"All LLM hosts failed for model {model}")
|
raise RuntimeError(f"All LLM hosts failed for model {model}")
|
||||||
|
|
||||||
|
|
||||||
def llm_json(prompt: str, model: str = "qwen3.5:4b", host: str = OLLAMA_MACBOOK,
|
def llm_json(prompt: str, model: str = "qwen3.5:4b-mlx", host: str = OLLAMA_MACBOOK,
|
||||||
system: str = "You are a JSON-only API. Always respond with valid JSON. No markdown, no explanation.",
|
system: str = "You are a JSON-only API. Always respond with valid JSON. No markdown, no explanation.",
|
||||||
temperature: float = 0.3) -> dict:
|
temperature: float = 0.3) -> dict:
|
||||||
"""Call LLM and parse JSON response."""
|
"""Call LLM and parse JSON response."""
|
||||||
@@ -233,7 +233,7 @@ def dual_llm_research(prompt: str, system: str = "") -> tuple[str, dict]:
|
|||||||
system=system, temperature=0.3, max_tokens=4096)
|
system=system, temperature=0.3, max_tokens=4096)
|
||||||
|
|
||||||
def call_qwen():
|
def call_qwen():
|
||||||
return llm_chat(prompt, model="qwen3.5:4b", host=OLLAMA_MACBOOK,
|
return llm_chat(prompt, model="qwen3.5:4b-mlx", host=OLLAMA_MACBOOK,
|
||||||
system=system, temperature=0.3, max_tokens=2048)
|
system=system, temperature=0.3, max_tokens=2048)
|
||||||
|
|
||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
||||||
@@ -429,7 +429,7 @@ Cover these verticals: AI/ML, general tech, science, cryptocurrency, Linux, gami
|
|||||||
Respond with a JSON array of strings, each a compelling article title."""
|
Respond with a JSON array of strings, each a compelling article title."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = llm_json(prompt, model="qwen3.5:4b", temperature=0.8)
|
result = llm_json(prompt, model="qwen3.5:4b-mlx", temperature=0.8)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
return result
|
return result
|
||||||
return list(result.values())[0] if result else []
|
return list(result.values())[0] if result else []
|
||||||
@@ -481,7 +481,7 @@ Vertical assignment rules:
|
|||||||
Respond with a JSON array of objects. No markdown, no explanation."""
|
Respond with a JSON array of objects. No markdown, no explanation."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = llm_json(prompt, model="qwen3.5:4b", temperature=0.3)
|
result = llm_json(prompt, model="qwen3.5:4b-mlx", temperature=0.3)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
# Apply algorithmic boost on top of LLM scores
|
# Apply algorithmic boost on top of LLM scores
|
||||||
return _apply_learning_boost(result, learning_insights)
|
return _apply_learning_boost(result, learning_insights)
|
||||||
@@ -634,7 +634,7 @@ Be accurate. Cite real sources. No hallucinations. Respond with ONLY valid JSON.
|
|||||||
system="You are an expert research analyst. You produce accurate, well-cited research. Never fabricate information.")
|
system="You are an expert research analyst. You produce accurate, well-cited research. Never fabricate information.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(f"Research LLM failed: {e}. Falling back to MacBook.")
|
log.error(f"Research LLM failed: {e}. Falling back to MacBook.")
|
||||||
result = llm_json(research_prompt, model="qwen3.5:4b",
|
result = llm_json(research_prompt, model="qwen3.5:4b-mlx",
|
||||||
system="You are an expert research analyst. Be accurate and honest.")
|
system="You are an expert research analyst. Be accurate and honest.")
|
||||||
|
|
||||||
# Store knowledge package
|
# Store knowledge package
|
||||||
@@ -864,7 +864,7 @@ Generate an outline appropriate for this format.
|
|||||||
Respond with JSON:
|
Respond with JSON:
|
||||||
{{"sections": [{{"heading": "...", "subsections": ["..."]}}, ...], "faq_questions": ["..."], "cta": "..."}}"""
|
{{"sections": [{{"heading": "...", "subsections": ["..."]}}, ...], "faq_questions": ["..."], "cta": "..."}}"""
|
||||||
|
|
||||||
outline = llm_json(outline_prompt, model="qwen3.5:4b", temperature=0.5)
|
outline = llm_json(outline_prompt, model="qwen3.5:4b-mlx", temperature=0.5)
|
||||||
|
|
||||||
# Agent 2: Draft with format guidance
|
# Agent 2: Draft with format guidance
|
||||||
draft_prompt = f"""Write a {fmt['name']} format article.
|
draft_prompt = f"""Write a {fmt['name']} format article.
|
||||||
@@ -903,14 +903,14 @@ ARTICLE:
|
|||||||
{draft}
|
{draft}
|
||||||
|
|
||||||
Return the edited article in full Markdown. No JSON wrapper.""",
|
Return the edited article in full Markdown. No JSON wrapper.""",
|
||||||
model="qwen3.5:4b", temperature=0.3, max_tokens=8192)
|
model="qwen3.5:4b-mlx", temperature=0.3, max_tokens=8192)
|
||||||
|
|
||||||
# Agent 4: SEO
|
# Agent 4: SEO
|
||||||
seo = llm_json(f"""Optimize this article for SEO.
|
seo = llm_json(f"""Optimize this article for SEO.
|
||||||
TITLE: {topic_title}
|
TITLE: {topic_title}
|
||||||
FIRST 500 CHARS: {edited[:500]}
|
FIRST 500 CHARS: {edited[:500]}
|
||||||
Respond with JSON: {{"seo_title": "...", "seo_description": "...", "keywords": ["..."]}}""",
|
Respond with JSON: {{"seo_title": "...", "seo_description": "...", "keywords": ["..."]}}""",
|
||||||
model="qwen3.5:4b", temperature=0.3)
|
model="qwen3.5:4b-mlx", temperature=0.3)
|
||||||
|
|
||||||
# Agent 5: Real Fact Check (web-verified)
|
# Agent 5: Real Fact Check (web-verified)
|
||||||
factcheck = real_fact_check(edited, topic_title)
|
factcheck = real_fact_check(edited, topic_title)
|
||||||
@@ -931,7 +931,7 @@ ARTICLE:
|
|||||||
{edited}
|
{edited}
|
||||||
|
|
||||||
Return the expanded article in full Markdown. No JSON wrapper.""",
|
Return the expanded article in full Markdown. No JSON wrapper.""",
|
||||||
model="qwen3.5:4b", temperature=0.5, max_tokens=8192)
|
model="qwen3.5:4b-mlx", temperature=0.5, max_tokens=8192)
|
||||||
passed, issues = quality_gate(edited, topic_title, vertical)
|
passed, issues = quality_gate(edited, topic_title, vertical)
|
||||||
|
|
||||||
if not passed:
|
if not passed:
|
||||||
|
|||||||
Reference in New Issue
Block a user