feat: 지서버용 별도 Ollama provider(ollama_local) 추가
기존 "ollama" provider(클로서버 localhost, 주로 *:cloud 모델용)는 그대로 두고, LAN의 다른 로컬 GPU 머신(지서버 등)을 가리키는 두 번째 독립 Ollama provider "ollama_local"을 신설. OllamaAdapter가 id를 생성자 인자로 받게 바꿔서(기존 'ollama' 하드코딩 → 'ollama'|'ollama_local' 선택 가능) 두 인스턴스를 provider 캐시/설정에서 구분함. 설정화면에 "Ollama (클로서버/클라우드)" / "Ollama (지서버/로컬)"로 라벨 분리, 엔드포인트·모델 입력 필드 추가. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9680fc96f
commit
b8c6a769be
6 files changed
+40
-8
No files matched your search
@@ -105,4 +105,4 @@ export interface LLMProvider {
|
||||
readonly id: ProviderID;
|
||||
}
|
||||
|
||||
export type ProviderID = 'ollama' | 'llama_cpp' | 'lm_studio' | 'openai' | 'openai_codex' | 'anthropic' | 'google';
|
||||
export type ProviderID = 'ollama' | 'ollama_local' | 'llama_cpp' | 'lm_studio' | 'openai' | 'openai_codex' | 'anthropic' | 'google';
|
||||
@@ -100,9 +100,11 @@ export function getProvider(): LLMProvider {
|
||||
const { active, providers } = getEffectiveProviderConfig();
|
||||
|
||||
if (cachedProvider && cachedProviderId === active) {
|
||||
// For Ollama, update endpoint in case it changed in settings
|
||||
// For Ollama (and the separate local-Ollama slot), update endpoint in case it changed in settings
|
||||
if (active === 'ollama' && cachedProvider instanceof OllamaAdapter) {
|
||||
cachedProvider.updateEndpoint(providers.ollama?.endpoint || 'http://localhost:11434');
|
||||
} else if (active === 'ollama_local' && cachedProvider instanceof OllamaAdapter && providers.ollama_local?.endpoint) {
|
||||
cachedProvider.updateEndpoint(providers.ollama_local.endpoint);
|
||||
}
|
||||
return cachedProvider;
|
||||
}
|
||||
@@ -147,6 +149,12 @@ function buildProvider(id: ProviderID, providers: any): LLMProvider {
|
||||
return new OllamaAdapter(cfg.endpoint || 'http://localhost:11434');
|
||||
}
|
||||
|
||||
case 'ollama_local': {
|
||||
const cfg = providers.ollama_local || {};
|
||||
if (!cfg.endpoint) throw new Error('Local Ollama endpoint not configured. Add it in Settings -> Models.');
|
||||
return new OllamaAdapter(cfg.endpoint, 'ollama_local');
|
||||
}
|
||||
|
||||
case 'llama_cpp': {
|
||||
const cfg = providers.llama_cpp || {};
|
||||
return new OpenAICompatAdapter({
|
||||
|
||||
@@ -343,12 +343,16 @@ function repairJson(input: string): string {
|
||||
}
|
||||
|
||||
export class OllamaAdapter implements LLMProvider {
|
||||
readonly id = 'ollama' as const;
|
||||
readonly id: 'ollama' | 'ollama_local';
|
||||
private client: Ollama;
|
||||
private endpoint: string;
|
||||
private _ctxCache: Map<string, number> = new Map();
|
||||
|
||||
constructor(endpoint: string) {
|
||||
// id defaults to 'ollama' (클로서버) for backward compat — pass 'ollama_local' for
|
||||
// a second, independently-configured Ollama host (e.g. 지서버) so usage logs, the
|
||||
// provider cache, and getProvider()'s live-endpoint-refresh all key off the right slot.
|
||||
constructor(endpoint: string, id: 'ollama' | 'ollama_local' = 'ollama') {
|
||||
this.id = id;
|
||||
this.endpoint = endpoint;
|
||||
this.client = new Ollama({ host: endpoint });
|
||||
}
|
||||
|
||||
+16
-1
@@ -1044,7 +1044,8 @@
|
||||
<div class="right-section-title" style="margin-bottom:8px">LLM 제공자</div>
|
||||
<label style="display:block;font-size:12px;color:var(--muted);margin-bottom:6px">백엔드</label>
|
||||
<select id="settings-llm-provider" class="settings-input" onchange="onProviderChange()" style="font-size:13px">
|
||||
<option value="ollama">Ollama (로컬)</option>
|
||||
<option value="ollama">Ollama (클로서버/클라우드)</option>
|
||||
<option value="ollama_local">Ollama (지서버/로컬)</option>
|
||||
<option value="llama_cpp">llama.cpp (로컬)</option>
|
||||
<option value="lm_studio">LM Studio (로컬)</option>
|
||||
<option value="openai">OpenAI — API 키</option>
|
||||
@@ -1076,6 +1077,20 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Ollama (second, independently-addressed instance — e.g. a GPU box on the LAN) -->
|
||||
<div id="prov-fields-ollama_local" style="display:none">
|
||||
<div class="right-section-title" style="margin-bottom:8px">Ollama (지서버/로컬) 연결</div>
|
||||
<label style="display:block;font-size:12px;color:var(--muted);margin-bottom:6px">엔드포인트</label>
|
||||
<input id="settings-ollamalocal-endpoint" type="text" placeholder="http://192.168.0.7:11434" style="width:100%;border:1px solid var(--line);border-radius:10px;padding:8px;font-size:12px;font-family:'IBM Plex Mono',monospace" />
|
||||
<label style="display:block;font-size:12px;color:var(--muted);margin:10px 0 6px">모델 이름</label>
|
||||
<input id="settings-ollamalocal-model" type="text" placeholder="e.g. gemma4:26b" style="width:100%;border:1px solid var(--line);border-radius:10px;padding:8px;font-size:12px;font-family:'IBM Plex Mono',monospace" />
|
||||
<div style="display:flex;gap:8px;margin-top:8px">
|
||||
<button class="btn btn-sm" onclick="testProviderConnection()" style="background:#fff;border:1px solid var(--line);color:var(--text)">연결 테스트</button>
|
||||
</div>
|
||||
<div id="provider-status-msg-ollamalocal" style="font-size:11px;color:var(--muted);margin-top:6px"></div>
|
||||
<div style="font-size:11px;color:var(--muted);margin-top:12px;line-height:1.6">클로서버 Ollama(위, 주로 클라우드 모델용)와 별개로, LAN의 다른 GPU 머신(예: 지서버)에서 도는 진짜 로컬 Ollama를 가리킵니다.</div>
|
||||
</div>
|
||||
|
||||
<!-- llama.cpp -->
|
||||
<div id="prov-fields-llama_cpp" style="display:none">
|
||||
<div class="right-section-title" style="margin-bottom:8px">llama.cpp 서버</div>
|
||||
|
||||
@@ -726,6 +726,8 @@ async function saveSettings() {
|
||||
const v = (id, val) => { const el = document.getElementById(id); if (el && val) el.value = val; };
|
||||
if (prov) { const el = document.getElementById('settings-llm-provider'); if (el) el.value = prov; }
|
||||
v('settings-ollama-endpoint', pc.ollama?.endpoint);
|
||||
v('settings-ollamalocal-endpoint', pc.ollama_local?.endpoint);
|
||||
v('settings-ollamalocal-model', pc.ollama_local?.model);
|
||||
v('settings-llamacpp-endpoint', pc.llama_cpp?.endpoint);
|
||||
v('settings-llamacpp-model', pc.llama_cpp?.model);
|
||||
v('settings-lmstudio-endpoint', pc.lm_studio?.endpoint);
|
||||
|
||||
@@ -291,7 +291,7 @@ function toggleCredVis(inputId, btn) {
|
||||
|
||||
// --- Provider-aware Model Settings ------------------------------------------
|
||||
|
||||
const PROVIDER_IDS = ['ollama', 'llama_cpp', 'lm_studio', 'openai', 'openai_codex', 'anthropic', 'google'];
|
||||
const PROVIDER_IDS = ['ollama', 'ollama_local', 'llama_cpp', 'lm_studio', 'openai', 'openai_codex', 'anthropic', 'google'];
|
||||
|
||||
function onProviderChange() {
|
||||
const provider = document.getElementById('settings-llm-provider').value;
|
||||
@@ -326,6 +326,8 @@ async function loadModelSettings() {
|
||||
// Populate each provider's fields from saved config
|
||||
const v = (id, val) => { const el = document.getElementById(id); if (el && val) el.value = val; };
|
||||
v('settings-ollama-endpoint', pc.ollama?.endpoint);
|
||||
v('settings-ollamalocal-endpoint', pc.ollama_local?.endpoint);
|
||||
v('settings-ollamalocal-model', pc.ollama_local?.model);
|
||||
v('settings-llamacpp-endpoint', pc.llama_cpp?.endpoint);
|
||||
v('settings-llamacpp-model', pc.llama_cpp?.model);
|
||||
v('settings-lmstudio-endpoint', pc.lm_studio?.endpoint);
|
||||
@@ -355,7 +357,7 @@ async function loadModelSettings() {
|
||||
if (prov === 'openai') await refreshOpenAIModels(true);
|
||||
|
||||
// Auto-load model list for list-capable providers (preserves saved selection)
|
||||
if (['ollama', 'lm_studio', 'llama_cpp'].includes(prov)) await refreshProviderModels(savedPrimaryModel);
|
||||
if (['ollama', 'ollama_local', 'lm_studio', 'llama_cpp'].includes(prov)) await refreshProviderModels(savedPrimaryModel);
|
||||
_modelSettingsLoaded = true;
|
||||
} catch (e) {
|
||||
console.warn('loadModelSettings error:', e);
|
||||
@@ -390,7 +392,7 @@ async function refreshProviderModels(forcedValue) {
|
||||
|
||||
async function testProviderConnection() {
|
||||
const provider = document.getElementById('settings-llm-provider').value;
|
||||
const statusIds = { ollama: 'provider-status-msg', llama_cpp: 'provider-status-msg-llamacpp', lm_studio: 'provider-status-msg-lmstudio', openai: 'provider-status-msg-openai', openai_codex: 'codex-oauth-status', anthropic: 'provider-status-msg-anthropic', google: 'provider-status-msg-google' };
|
||||
const statusIds = { ollama: 'provider-status-msg', ollama_local: 'provider-status-msg-ollamalocal', llama_cpp: 'provider-status-msg-llamacpp', lm_studio: 'provider-status-msg-lmstudio', openai: 'provider-status-msg-openai', openai_codex: 'codex-oauth-status', anthropic: 'provider-status-msg-anthropic', google: 'provider-status-msg-google' };
|
||||
const msgId = statusIds[provider] || 'provider-status-msg';
|
||||
const msg = document.getElementById(msgId);
|
||||
if (msg) msg.textContent = '테스트 중…';
|
||||
@@ -451,6 +453,7 @@ function buildProviderPayload() {
|
||||
const provider = document.getElementById('settings-llm-provider')?.value || 'ollama';
|
||||
const providers = {};
|
||||
providers.ollama = { endpoint: document.getElementById('settings-ollama-endpoint')?.value || 'http://localhost:11434', model: document.getElementById('settings-primary-model')?.value || '' };
|
||||
providers.ollama_local = { endpoint: document.getElementById('settings-ollamalocal-endpoint')?.value || '', model: document.getElementById('settings-ollamalocal-model')?.value || '' };
|
||||
providers.llama_cpp = { endpoint: document.getElementById('settings-llamacpp-endpoint')?.value || 'http://localhost:8080', model: document.getElementById('settings-llamacpp-model')?.value || '' };
|
||||
providers.lm_studio = { endpoint: document.getElementById('settings-lmstudio-endpoint')?.value || 'http://localhost:1234', model: document.getElementById('settings-lmstudio-model')?.value || '', disable_thinking: !!document.getElementById('settings-lmstudio-disable-thinking')?.checked };
|
||||
providers.openai = { api_key: document.getElementById('settings-openai-key')?.value || '', model: document.getElementById('settings-openai-model')?.value || 'gpt-4o' };
|
||||
|
||||
Reference in new issue
Block a user