올라마 클라우드 직접 호출 정리 — 스튜디오 프롬프트 도우미·PPTX 그림 캡션을 활성 provider로
올라마 유료 구독이 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 <noreply@anthropic.com>
This commit is contained in:
1 parent
34455c4603
commit
896561c909
3 files changed
+22
-30
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user