diff --git a/src/gateway/memory/memory-rerank.ts b/src/gateway/memory/memory-rerank.ts index 77fd173..de0243c 100644 --- a/src/gateway/memory/memory-rerank.ts +++ b/src/gateway/memory/memory-rerank.ts @@ -12,10 +12,9 @@ import { getConfig } from '../../config/config.js'; import { lightChat } from '../../providers/light-chat.js'; -// "flash"-tier model chosen specifically for latency, not quality — this call is a small -// classification task (pick relevant indices from a short list), not a task worth spending -// primary-model-grade reasoning time on. Revisit if this model is ever unpulled/renamed. -const RERANK_MODEL = 'gemma4:31b-cloud'; +// 모델은 lightChat()이 활성 provider의 싼 모델(Anthropic이면 Haiku)로 정한다 — 이 호출은 짧은 목록에서 관련 +// 항목 번호를 고르는 분류 작업이라 주 모델급 추론이 필요 없다. (예전에 여기 박혀 있던 올라마 클라우드 모델 +// 상수는 10-17 lightChat 전환 후 쓰이지 않아 2026-10-30 제거 — 올라마 구독이 끝나도 영향 없음.) // Only fires on genuinely ambiguous retrieval (see the gating in personality-context.ts) — // most turns never reach this call at all, so a generous timeout here doesn't cost anything // on the common path. 8s was measured to occasionally clip real (successful, just slow) diff --git a/src/gateway/routes/imagegen.ts b/src/gateway/routes/imagegen.ts index ab2d690..8013456 100644 --- a/src/gateway/routes/imagegen.ts +++ b/src/gateway/routes/imagegen.ts @@ -447,25 +447,16 @@ export function registerImagegenRoutes(app: Express): void { : `당신은 이미지/동영상 생성 스튜디오 앱에 내장된 프롬프트 작성 도우미입니다. 사용자가 한국어로 설명하는 이미지를 SDXL/FLUX 같은 이미지 diffusion 모델에 적합한 영어 프롬프트로 다듬어주세요 (스타일, 조명, 구도, 디테일 태그 포함). 대화는 한국어로 하되, 답변 맨 끝에는 반드시 아래 형식의 블록을 붙이세요:\n\`\`\`\nPROMPT: <영어 프롬프트>\nNEGATIVE: <네거티브 프롬프트, 없으면 빈 칸>\n\`\`\``; try { - const { getConfig } = await import('../../config/config.js'); - const rawCfg = getConfig().getConfig() as any; - const provider: string = rawCfg.llm?.provider || 'ollama'; - const model: string = rawCfg.llm?.providers?.[provider]?.model || rawCfg.models?.primary || 'gemma4:31b-cloud'; - const endpoint: string = rawCfg.ollama?.endpoint || 'http://localhost:11434'; - - const r = await fetch(`${endpoint}/api/chat`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - model, - messages: [{ role: 'system', content: systemPrompt }, ...messages], - stream: false, - }), - signal: AbortSignal.timeout(60_000), - }); - if (!r.ok) return res.status(502).json({ error: `ollama HTTP ${r.status}` }); - const data: any = await r.json(); - const reply = String(data?.message?.content || '').trim(); + // 2026-10-30: 올라마 /api/chat에 활성 모델명을 그대로 보내던 것을 provider 추상화(lightChat)로 교체 — + // 주 모델이 Anthropic이면 'claude-haiku-5-5'가 올라마로 가서 404였고, 올라마 구독이 끝나도 안 깨지게 한다. + const { lightChat } = await import('../../providers/light-chat.js'); + const chatMessages = [ + { role: 'system' as const, content: systemPrompt }, + ...messages + .filter((m: any) => m && (m.role === 'user' || m.role === 'assistant')) + .map((m: any) => ({ role: m.role as 'user' | 'assistant', content: String(m.content ?? '') })), + ]; + const reply = await lightChat(chatMessages, { max_tokens: 1500, temperature: 0.6, timeoutMs: 60_000 }); if (!reply) return res.status(502).json({ error: 'empty response from model' }); res.json({ reply }); } catch (err: any) { diff --git a/src/gateway/routes/routes-pptx.ts b/src/gateway/routes/routes-pptx.ts index 22a13e2..4430930 100644 --- a/src/gateway/routes/routes-pptx.ts +++ b/src/gateway/routes/routes-pptx.ts @@ -1,9 +1,10 @@ -import { visionModelOverride } from '../../providers/light-chat.js'; +import { visionModelOverride, lightModel } from '../../providers/light-chat.js'; +import { getProvider } from '../../providers/factory.js'; +import { contentToString } from '../../providers/content-utils.js'; import express from 'express'; import path from 'path'; import fs from 'fs'; import { getConfig, getUserWorkspace } from '../../config/config'; -import { getOllamaClient } from '../../agents/ollama-client'; import { filterImageMarkdown } from '../guards/link-validator'; import { toPaperSearchQuery } from '../../tools/query-translate.js'; import { getToolRegistry } from '../../tools/registry.js'; @@ -913,20 +914,21 @@ app.post('/api/pptx/analyze-image', requireGatewayAuth, async (req: express.Requ const b64 = `data:${mime};base64,${buf.toString('base64')}`; // Call vision model - const ollama2 = getOllamaClient(); + // 2026-10-30: 올라마 클라이언트를 직접 부르던 것을 활성 provider의 싼 비전 모델(Claude·Gemini·GPT는 모두 비전 지원)로. + // 올라마가 활성일 때만 예전처럼 비전용 올라마 모델을 쓴다(visionModelOverride). const rawCfg2 = getConfig().getConfig() as any; const sec2 = rawCfg2.orchestration?.secondary; - const visionModel = (sec2?.model && sec2?.vision === true) ? sec2.model : visionModelOverride('mistral-large-3:675b-cloud'); + const visionModel = (sec2?.model && sec2?.vision === true) ? sec2.model : (visionModelOverride('mistral-large-3:675b-cloud') || lightModel()); - const result = await ollama2.chatWithThinking([{ + const result: any = await getProvider().chat([{ role: 'user' as const, content: [ { type: 'text' as const, text: '이 그림을 한 줄(30자 이내)로 설명하세요. 그래프/차트/다이어그램 종류와 핵심 내용 위주로. 슬라이드에 쓰기 부적합한 그림(흐릿함·텍스트만 있는 표·빈 이미지)이면 "제외"라고만 답하세요.' }, { type: 'image_url' as const, image_url: { url: b64 } }, ], - }], 'executor', { model: visionModel, num_predict: 80 }); + }] as any, visionModel, { max_tokens: 100, temperature: 0.2 } as any); - const caption = String(result.message?.content || '').trim().replace(/\n/g, ' ').slice(0, 80); + const caption = contentToString(result?.message?.content ?? '').trim().replace(/\n/g, ' ').slice(0, 80); cached[imgUrl] = caption; if (cacheFile) { try {