fix: use Ollama container directly for MiroFlow scientific agents

- Replace LiteLLM with direct Ollama API (ollama-ia1upsekrad96at5hq97e4qa)
- Use deepseek-r1:14b for all agents, fallback to llama3.2:3b
- OLLAMA_BASE_URL env var overrides default hostname

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jonas Pacheco 2026-03-31 21:53:38 -03:00
parent 59bfca8c70
commit 9d83163dbb
1 changed files with 8 additions and 5 deletions

View File

@ -7,7 +7,7 @@ const MIROFLOW_URL = `http://${MIROFLOW_HOST}:${MIROFLOW_PORT}`;
const MIROFLOW_TIMEOUT = 600_000; // 10 minutos const MIROFLOW_TIMEOUT = 600_000; // 10 minutos
const MIROFLOW_HEALTH_TIMEOUT = 5_000; const MIROFLOW_HEALTH_TIMEOUT = 5_000;
const OLLAMA_URL = process.env.OLLAMA_URL || "http://localhost:11434"; const OLLAMA_URL = process.env.OLLAMA_BASE_URL || "http://ollama-ia1upsekrad96at5hq97e4qa:11434";
const AGENT_CONFIGS: Record<string, { model: string; system: string }> = { const AGENT_CONFIGS: Record<string, { model: string; system: string }> = {
statistician: { statistician: {
@ -35,7 +35,7 @@ const AGENT_CONFIGS: Record<string, { model: string; system: string }> = {
const FALLBACK_MODEL = "llama3.2:3b"; const FALLBACK_MODEL = "llama3.2:3b";
async function callOllama(model: string, system: string, prompt: string): Promise<string> { async function callLLM(model: string, system: string, prompt: string): Promise<string> {
const controller = new AbortController(); const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 300_000); const timeout = setTimeout(() => controller.abort(), 300_000);
try { try {
@ -53,7 +53,10 @@ async function callOllama(model: string, system: string, prompt: string): Promis
signal: controller.signal, signal: controller.signal,
}); });
clearTimeout(timeout); clearTimeout(timeout);
if (!resp.ok) throw new Error(`Ollama error: ${resp.status}`); if (!resp.ok) {
const err = await resp.json().catch(() => ({ error: resp.statusText }));
throw new Error(err?.error ?? `Ollama error: ${resp.status}`);
}
const data: any = await resp.json(); const data: any = await resp.json();
return data.message?.content ?? ""; return data.message?.content ?? "";
} catch (err: any) { } catch (err: any) {
@ -126,10 +129,10 @@ export function registerMiroFlowRoutes(app: Express): void {
let result: string; let result: string;
try { try {
result = await callOllama(model, cfg.system, prompt); result = await callLLM(model, cfg.system, prompt);
} catch { } catch {
model = FALLBACK_MODEL; model = FALLBACK_MODEL;
result = await callOllama(model, cfg.system, prompt); result = await callLLM(model, cfg.system, prompt);
} }
res.json({ res.json({