From 896561c90955f69388fc0a228916a14fd38ca922 Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 31 Oct 2026 00:05:06 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=AC=EB=9D=BC=EB=A7=88=20=ED=81=B4?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=EB=93=9C=20=EC=A7=81=EC=A0=91=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EC=A0=95=EB=A6=AC=20=E2=80=94=20=EC=8A=A4=ED=8A=9C?= =?UTF-8?q?=EB=94=94=EC=98=A4=20=ED=94=84=EB=A1=AC=ED=94=84=ED=8A=B8=20?= =?UTF-8?q?=EB=8F=84=EC=9A=B0=EB=AF=B8=C2=B7PPTX=20=EA=B7=B8=EB=A6=BC=20?= =?UTF-8?q?=EC=BA=A1=EC=85=98=EC=9D=84=20=ED=99=9C=EC=84=B1=20provider?= =?UTF-8?q?=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 올라마 유료 구독이 11월 중순에 끝날 예정이라 `-cloud` 모델 의존을 줄인다. - /api/studio/prompt-assist: 활성 모델명(주 모델이 Anthropic이면 claude-haiku-5-5)을 올라마 /api/chat에 그대로 보내 404가 나던 것을 lightChat(활성 provider의 싼 모델)으로 교체. 시스템 프롬프트·대화 이력은 그대로 전달. - PPTX 그림 캡션: getOllamaClient().chatWithThinking('executor') 직접 호출을 getProvider().chat(활성 provider 비전 모델, 올라마가 활성일 때만 예전처럼 비전용 올라마 모델)로 교체. 쓰이지 않게 된 getOllamaClient import 제거. - memory-rerank: 10-17 lightChat 전환 후 쓰이지 않던 RERANK_MODEL('gemma4:31b-cloud') 상수 제거(재순위는 이미 Haiku). Co-Authored-By: Claude Sonnet 5.5 --- src/gateway/memory/memory-rerank.ts | 7 +++---- src/gateway/routes/imagegen.ts | 29 ++++++++++------------------- src/gateway/routes/routes-pptx.ts | 16 +++++++++------- 3 files changed, 22 insertions(+), 30 deletions(-) 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 {