feat: ollama support

This commit is contained in:
2026-03-01 21:31:33 +01:00
parent 4daa5f450b
commit 9fdbccc687
15 changed files with 796 additions and 25 deletions

View File

@@ -16,7 +16,7 @@ import type { BrowserWindow } from 'electron';
import type { ChatEngine, ChatMessageData } from '../ChatEngine';
import { isRenderTool, generateFromToolCall } from '../../a2ui/generator';
import type { A2UIServerMessage } from '../../a2ui/types';
import { ProviderRegistry, detectProvider } from './providers';
import { ProviderRegistry } from './providers';
import { createBlogTools, type BlogToolDeps } from './blog-tools';
import { createA2UITools } from './a2ui-tools';
@@ -247,11 +247,11 @@ export class ChatService {
this.abortControllers.set(conversationId, abortController);
const modelId = conversation.model || 'claude-sonnet-4';
const provider = detectProvider(modelId);
const provider = this.providers.detectModelProvider(modelId);
// Verify provider key is available
if (!this.providers.isProviderKeySet(provider)) {
const providerLabel = provider === 'mistral' ? 'Mistral' : 'OpenCode';
const providerLabel = provider === 'mistral' ? 'Mistral' : provider === 'ollama' ? 'Ollama' : 'OpenCode';
return { success: false, error: `The model '${modelId}' requires a ${providerLabel} API key. Configure it in Settings.` };
}
@@ -271,10 +271,13 @@ export class ChatService {
const aiMessages = dbMessagesToAIMessages(dbMessages);
// Build tools
const blogTools = createBlogTools(this.blogToolDeps);
const a2uiToolsRaw = createA2UITools();
// Build tools (skip for Ollama models unless capability override is set)
const isOllama = this.providers.isOllamaModel(modelId);
const skipTools = isOllama && !this.providers.ollamaModelSupportsTools(modelId);
const blogTools = skipTools ? {} : createBlogTools(this.blogToolDeps);
const a2uiToolsRaw = skipTools ? {} : createA2UITools();
const allTools = { ...blogTools, ...a2uiToolsRaw };
const hasTools = Object.keys(allTools).length > 0;
// Get context window for truncation
const contextWindow = await this.providers.getModelCatalogEngine().getContextWindow(modelId) ?? 150_000;
@@ -301,12 +304,14 @@ export class ChatService {
try {
// --- streamText: the AI SDK replaces our entire SSE/accumulator/tool-loop ---
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- tools may be empty for Ollama models
const toolsOption = hasTools ? allTools : undefined as any;
const result = streamText({
model,
system: systemPrompt,
messages: truncatedMessages,
tools: allTools,
stopWhen: stepCountIs(MAX_TOOL_ROUNDS),
tools: toolsOption,
stopWhen: hasTools ? stepCountIs(MAX_TOOL_ROUNDS) : undefined,
abortSignal: abortController.signal,
maxRetries: 3,
providerOptions,
@@ -435,7 +440,7 @@ export class ChatService {
let titleModel = await this.chatEngine.getSetting('chat_title_model');
// Fallback chain: setting → haiku → mistral-small
if (!titleModel || !this.providers.isProviderKeySet(detectProvider(titleModel))) {
if (!titleModel || !this.providers.isProviderKeySet(this.providers.detectModelProvider(titleModel))) {
titleModel = this.providers.getOpencodeKey()
? 'claude-haiku-4-5'
: this.providers.getMistralKey()

View File

@@ -27,8 +27,11 @@ import type { ChatModel } from '../../shared/electronApi';
export const ZEN_BASE_URL = 'https://opencode.ai/zen/v1';
export const ZEN_MODELS_URL = 'https://opencode.ai/zen/v1/models';
export const MISTRAL_MODELS_URL = 'https://api.mistral.ai/v1/models';
export const OLLAMA_BASE_URL = 'http://localhost:11434/v1';
export const OLLAMA_TAGS_URL = 'http://localhost:11434/api/tags';
const MODEL_CACHE_TTL = 5 * 60 * 1000; // 5 minutes
const OLLAMA_FETCH_TIMEOUT = 3000; // 3 s — fail fast when Ollama isn't running
// ---------------------------------------------------------------------------
// Gateway factory
@@ -99,8 +102,12 @@ export function detectProvider(modelId: string): string {
export class ProviderRegistry {
private opencodeKey = '';
private mistralKey = '';
private ollamaEnabled = false;
private opencodeGateway: Provider | null = null;
private mistralProvider: ReturnType<typeof createMistral> | null = null;
private ollamaProvider: ReturnType<typeof createOpenAI> | null = null;
private ollamaModelIds = new Set<string>();
private ollamaCapabilities = new Map<string, { tools: boolean; vision: boolean }>();
private modelCatalogEngine = new ModelCatalogEngine();
// Model cache
@@ -129,22 +136,100 @@ export class ProviderRegistry {
return this.mistralKey;
}
// ---- Ollama management ----
setOllamaEnabled(enabled: boolean): void {
this.ollamaEnabled = enabled;
this.ollamaProvider = null;
this.invalidateModelCache();
}
isOllamaEnabled(): boolean {
return this.ollamaEnabled;
}
/** Register a model ID as belonging to Ollama. */
registerOllamaModel(modelId: string): void {
this.ollamaModelIds.add(modelId);
}
/** Check whether a model ID was registered as an Ollama model. */
isOllamaModel(modelId: string): boolean {
return this.ollamaModelIds.has(modelId);
}
/** Remove all registered Ollama model IDs. */
clearOllamaModels(): void {
this.ollamaModelIds.clear();
}
// ---- Ollama model capability overrides ----
/** Get capability overrides for a specific Ollama model (defaults to tools=false, vision=false). */
getOllamaModelCapabilities(modelId: string): { tools: boolean; vision: boolean } {
return this.ollamaCapabilities.get(modelId) ?? { tools: false, vision: false };
}
/** Set capability overrides for a specific Ollama model. */
setOllamaModelCapabilities(modelId: string, caps: { tools: boolean; vision: boolean }): void {
this.ollamaCapabilities.set(modelId, caps);
this.invalidateModelCache();
}
/** Get all stored capability overrides as a plain object. */
getAllOllamaModelCapabilities(): Record<string, { tools: boolean; vision: boolean }> {
const result: Record<string, { tools: boolean; vision: boolean }> = {};
for (const [id, caps] of this.ollamaCapabilities) {
result[id] = caps;
}
return result;
}
/** Load capability overrides from a serialized object (e.g. from settings DB). */
loadOllamaModelCapabilities(data: Record<string, { tools: boolean; vision: boolean }>): void {
this.ollamaCapabilities.clear();
for (const [id, caps] of Object.entries(data)) {
this.ollamaCapabilities.set(id, caps);
}
}
/** Check whether an Ollama model has tools capability enabled. */
ollamaModelSupportsTools(modelId: string): boolean {
return this.ollamaCapabilities.get(modelId)?.tools ?? false;
}
/** Check whether an Ollama model has vision capability enabled. */
ollamaModelSupportsVision(modelId: string): boolean {
return this.ollamaCapabilities.get(modelId)?.vision ?? false;
}
/**
* Detect the effective provider for a model ID, checking Ollama
* registration first, then falling back to prefix-based detection.
*/
detectModelProvider(modelId: string): string {
if (this.ollamaModelIds.has(modelId)) return 'ollama';
return detectProvider(modelId);
}
/** Check whether at least one provider key is configured. */
isReady(): boolean {
return !!(this.opencodeKey || this.mistralKey);
return !!(this.opencodeKey || this.mistralKey || this.ollamaEnabled);
}
/** Check whether the key for a specific provider is set. */
isProviderKeySet(provider: string): boolean {
if (provider === 'mistral') return !!this.mistralKey;
if (provider === 'ollama') return this.ollamaEnabled;
return !!this.opencodeKey;
}
/** Returns status of all configured providers. */
getProviderStatus(): { opencode: boolean; mistral: boolean } {
getProviderStatus(): { opencode: boolean; mistral: boolean; ollama: boolean } {
return {
opencode: !!this.opencodeKey,
mistral: !!this.mistralKey,
ollama: this.ollamaEnabled,
};
}
@@ -152,6 +237,20 @@ export class ProviderRegistry {
/** Resolve a model ID to an AI SDK LanguageModel. */
resolveModel(modelId: string): LanguageModel {
// Check if this is a registered Ollama model first
if (this.ollamaModelIds.has(modelId)) {
if (!this.ollamaEnabled) {
throw new Error(`Ollama not configured for model '${modelId}'`);
}
if (!this.ollamaProvider) {
this.ollamaProvider = createOpenAI({
baseURL: OLLAMA_BASE_URL,
apiKey: 'ollama', // Ollama doesn't need a real key
});
}
return this.ollamaProvider.chat(modelId);
}
const provider = detectProvider(modelId);
if (provider === 'mistral') {
@@ -229,6 +328,17 @@ export class ProviderRegistry {
}
}
// Fetch Ollama models
if (this.ollamaEnabled) {
try {
const models = await this.fetchOllamaModels();
allModels.push(...models);
if (models.length > 0) fetched = true;
} catch {
// Ollama not running — skip silently
}
}
if (fetched && allModels.length > 0) {
this.cachedModels = allModels;
this.cachedModelsAt = Date.now();
@@ -283,6 +393,39 @@ export class ProviderRegistry {
}
}
// ---- Ollama model listing ----
/**
* Fetch available models from Ollama's /api/tags endpoint.
* Returns ChatModel[] and registers the model IDs internally.
*/
async fetchOllamaModels(): Promise<ChatModel[]> {
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), OLLAMA_FETCH_TIMEOUT);
const response = await fetch(OLLAMA_TAGS_URL, { method: 'GET', signal: controller.signal });
clearTimeout(timeout);
if (!response.ok) return [];
const data = await response.json() as { models?: Array<{ name: string; details?: { family?: string } }> };
if (!data.models || !Array.isArray(data.models)) return [];
this.clearOllamaModels();
const models: ChatModel[] = data.models.map(m => {
this.registerOllamaModel(m.name);
return {
id: m.name,
name: m.name,
provider: 'ollama',
vision: this.ollamaModelSupportsVision(m.name),
};
});
return models;
} catch {
return [];
}
}
// ---- Private helpers ----
private async fetchModelsFromEndpoint(

View File

@@ -8,7 +8,7 @@
import { generateText } from 'ai';
import type { ChatEngine } from '../ChatEngine';
import type { MediaEngine } from '../MediaEngine';
import { ProviderRegistry, detectProvider } from './providers';
import { ProviderRegistry } from './providers';
// ---------------------------------------------------------------------------
// Types
@@ -68,9 +68,9 @@ export class OneShotTasks {
tags: Array<{ name: string; slug: string; existsInProject: boolean }>,
modelId: string,
): Promise<TaxonomyAnalysisResult> {
const provider = detectProvider(modelId);
const provider = this.providers.detectModelProvider(modelId);
if (!this.providers.isProviderKeySet(provider)) {
const providerLabel = provider === 'mistral' ? 'Mistral' : 'OpenCode';
const providerLabel = provider === 'mistral' ? 'Mistral' : provider === 'ollama' ? 'Ollama' : 'OpenCode';
return { success: false, error: `${providerLabel} API key not set` };
}
@@ -187,7 +187,7 @@ Remember: Only suggest mappings from NEW items to EXISTING items. Consider langu
): Promise<ImageAnalysisResult> {
// Determine model with smart fallback
let modelId = await this.chatEngine.getSetting('chat_image_analysis_model');
if (!modelId || !this.providers.isProviderKeySet(detectProvider(modelId))) {
if (!modelId || !this.providers.isProviderKeySet(this.providers.detectModelProvider(modelId))) {
modelId = this.providers.getOpencodeKey()
? 'claude-sonnet-4-5'
: this.providers.getMistralKey()

View File

@@ -109,6 +109,21 @@ async function ensureInitialized(): Promise<void> {
const mistralKey = await keyStore.retrieve('mistral_api_key');
if (mistralKey) reg.setMistralKey(mistralKey);
} catch { /* ignore */ }
// Restore Ollama enabled state from settings DB
try {
const ollamaEnabled = await getChatEngine().getSetting('ollama_enabled');
if (ollamaEnabled === 'true') reg.setOllamaEnabled(true);
} catch { /* ignore */ }
// Restore Ollama model capability overrides
try {
const capsJson = await getChatEngine().getSetting('ollama_model_capabilities');
if (capsJson) {
const caps = JSON.parse(capsJson) as Record<string, { tools: boolean; vision: boolean }>;
reg.loadOllamaModelCapabilities(caps);
}
} catch { /* ignore */ }
})();
}
await initPromise;
@@ -237,6 +252,74 @@ export function registerChatHandlers(): void {
}
});
// ============ Ollama (Local) ============
// Get Ollama enabled state
ipcMain.handle('chat:getOllamaEnabled', async () => {
try {
await ensureInitialized();
return getProviders().isOllamaEnabled();
} catch (error) {
console.error('[Chat IPC] Error getting Ollama enabled state:', error);
return false;
}
});
// Set Ollama enabled state
ipcMain.handle('chat:setOllamaEnabled', async (_, enabled: boolean) => {
try {
await ensureInitialized();
const reg = getProviders();
reg.setOllamaEnabled(enabled);
// Persist to settings DB
await getChatEngine().setSetting('ollama_enabled', enabled ? 'true' : 'false');
return { success: true };
} catch (error) {
console.error('[Chat IPC] Error setting Ollama enabled state:', error);
return { success: false, error: (error as Error).message };
}
});
// Get Ollama models (probe local server)
ipcMain.handle('chat:getOllamaModels', async () => {
try {
await ensureInitialized();
return await getProviders().fetchOllamaModels();
} catch (error) {
console.error('[Chat IPC] Error fetching Ollama models:', error);
return [];
}
});
// Get Ollama model capability overrides
ipcMain.handle('chat:getOllamaModelCapabilities', async () => {
try {
await ensureInitialized();
return getProviders().getAllOllamaModelCapabilities();
} catch (error) {
console.error('[Chat IPC] Error getting Ollama model capabilities:', error);
return {};
}
});
// Set capability overrides for a single Ollama model
ipcMain.handle('chat:setOllamaModelCapabilities', async (_, modelId: string, caps: { tools: boolean; vision: boolean }) => {
try {
await ensureInitialized();
const reg = getProviders();
reg.setOllamaModelCapabilities(modelId, caps);
// Persist all capabilities to settings DB
const allCaps = reg.getAllOllamaModelCapabilities();
await getChatEngine().setSetting('ollama_model_capabilities', JSON.stringify(allCaps));
return { success: true };
} catch (error) {
console.error('[Chat IPC] Error setting Ollama model capabilities:', error);
return { success: false, error: (error as Error).message };
}
});
// ============ Per-Purpose Model Preferences ============
// Get title generation model

View File

@@ -314,6 +314,13 @@ export const electronAPI: ElectronAPI = {
setMistralApiKey: (apiKey: string) => ipcRenderer.invoke('chat:setMistralApiKey', apiKey),
getMistralApiKey: () => ipcRenderer.invoke('chat:getMistralApiKey'),
// Ollama (Local)
getOllamaEnabled: () => ipcRenderer.invoke('chat:getOllamaEnabled'),
setOllamaEnabled: (enabled: boolean) => ipcRenderer.invoke('chat:setOllamaEnabled', enabled),
getOllamaModels: () => ipcRenderer.invoke('chat:getOllamaModels'),
getOllamaModelCapabilities: () => ipcRenderer.invoke('chat:getOllamaModelCapabilities'),
setOllamaModelCapabilities: (modelId: string, caps: { tools: boolean; vision: boolean }) => ipcRenderer.invoke('chat:setOllamaModelCapabilities', modelId, caps),
// Per-Purpose Model Preferences
getTitleModel: () => ipcRenderer.invoke('chat:getTitleModel'),
setTitleModel: (modelId: string | null) => ipcRenderer.invoke('chat:setTitleModel', modelId),

View File

@@ -451,7 +451,7 @@ export interface ChatReadyStatus {
ready: boolean;
error?: string;
backend?: string;
providers?: { opencode: boolean; mistral: boolean };
providers?: { opencode: boolean; mistral: boolean; ollama: boolean };
}
export interface ChatApiKeyStatus {
@@ -832,6 +832,13 @@ export interface ElectronAPI {
setMistralApiKey: (apiKey: string) => Promise<{ success: boolean; error?: string }>;
getMistralApiKey: () => Promise<ChatApiKeyStatus>;
// Ollama (local)
getOllamaEnabled: () => Promise<boolean>;
setOllamaEnabled: (enabled: boolean) => Promise<{ success: boolean; error?: string }>;
getOllamaModels: () => Promise<ChatModel[]>;
getOllamaModelCapabilities: () => Promise<Record<string, { tools: boolean; vision: boolean }>>;
setOllamaModelCapabilities: (modelId: string, caps: { tools: boolean; vision: boolean }) => Promise<{ success: boolean; error?: string }>;
// Settings
getAvailableModels: () => Promise<{ success: boolean; models?: ChatModel[]; selectedModel?: string; error?: string }>;
setDefaultModel: (modelId: string) => Promise<{ success: boolean; error?: string }>;

View File

@@ -532,3 +532,36 @@
gap: 8px;
margin-top: 8px;
}
/* Ollama model capabilities table */
.ollama-model-capabilities {
margin-top: 12px;
}
.ollama-model-capabilities .setting-description {
display: block;
margin-bottom: 8px;
}
.ollama-caps-table {
width: 100%;
border-collapse: collapse;
font-size: 0.9em;
}
.ollama-caps-table th,
.ollama-caps-table td {
padding: 4px 8px;
text-align: left;
border-bottom: 1px solid var(--pico-muted-border-color, #ccc);
}
.ollama-caps-table th:not(:first-child),
.ollama-caps-table td:not(:first-child) {
text-align: center;
width: 80px;
}
.ollama-caps-table input[type="checkbox"] {
margin: 0;
}

View File

@@ -245,6 +245,9 @@ export const SettingsView: React.FC = () => {
const [aiHasMistralKey, setAiHasMistralKey] = useState(false);
const [aiMistralKeyMasked, setAiMistralKeyMasked] = useState('');
const [newMistralKey, setNewMistralKey] = useState('');
const [ollamaEnabled, setOllamaEnabled] = useState(false);
const [ollamaCapabilities, setOllamaCapabilities] = useState<Record<string, { tools: boolean; vision: boolean }>>({});
const [ollamaModels, setOllamaModels] = useState<{id: string; name: string}[]>([]);
const [titleModel, setTitleModel] = useState('claude-haiku-4-5');
const [imageAnalysisModel, setImageAnalysisModel] = useState('claude-sonnet-4-5');
const [availableModels, setAvailableModels] = useState<{id: string; name: string; provider?: string; vision?: boolean}[]>([]);
@@ -415,6 +418,20 @@ export const SettingsView: React.FC = () => {
setAiMistralKeyMasked(mistralKeyResult.maskedKey || '');
}
// Load Ollama enabled state
const ollamaState = await window.electronAPI?.chat.getOllamaEnabled();
setOllamaEnabled(!!ollamaState);
// Load Ollama model capabilities and models list
if (ollamaState) {
const [caps, models] = await Promise.all([
window.electronAPI?.chat.getOllamaModelCapabilities(),
window.electronAPI?.chat.getOllamaModels(),
]);
if (caps) setOllamaCapabilities(caps);
if (models) setOllamaModels(models.map(m => ({ id: m.id, name: m.name })));
}
// Load per-purpose model preferences
const titleModelResult = await window.electronAPI?.chat.getTitleModel();
if (titleModelResult?.success && titleModelResult.modelId) {
@@ -536,7 +553,7 @@ export const SettingsView: React.FC = () => {
const projectKeywords = ['project', 'name', 'description', 'blog', 'site', 'url', 'public', 'path', 'folder', 'location', 'data', 'language', 'author', 'default', 'preview', 'max', 'posts', 'page', 'bookmarklet', 'blogmark'];
const editorKeywords = ['editor', 'mode', 'wysiwyg', 'markdown', 'preview', 'visual'];
const contentKeywords = ['content', 'categories', 'post', 'article', 'picture', 'aside', 'page'];
const aiKeywords = ['ai', 'assistant', 'chat', 'model', 'prompt', 'system', 'api', 'key', 'claude', 'gpt', 'opencode'];
const aiKeywords = ['ai', 'assistant', 'chat', 'model', 'prompt', 'system', 'api', 'key', 'claude', 'gpt', 'opencode', 'ollama', 'local'];
const technologyKeywords = ['technology', 'python', 'runtime', 'worker', 'webworker', 'main thread', 'execution'];
const publishingKeywords = ['publishing', 'ssh', 'deploy', 'server', 'host', 'upload', 'scp', 'rsync'];
const dataKeywords = ['data', 'database', 'rebuild', 'maintenance', 'posts', 'media', 'scripts', 'links', 'folder', 'filesystem'];
@@ -1144,6 +1161,55 @@ export const SettingsView: React.FC = () => {
}
};
const handleOllamaToggle = async (enabled: boolean) => {
try {
const result = await window.electronAPI?.chat.setOllamaEnabled(enabled);
if (result?.success) {
setOllamaEnabled(enabled);
showToast.success(t(enabled ? 'settings.toast.ollamaEnabled' : 'settings.toast.ollamaDisabled'));
// Refresh models after toggle
const modelsResult = await window.electronAPI?.chat.getAvailableModels();
if (modelsResult?.success && modelsResult.models) {
setAvailableModels(modelsResult.models);
setSelectedModel(modelsResult.selectedModel || '');
}
// Load Ollama models and capabilities when enabling
if (enabled) {
const [caps, ollamaModelsList] = await Promise.all([
window.electronAPI?.chat.getOllamaModelCapabilities(),
window.electronAPI?.chat.getOllamaModels(),
]);
if (caps) setOllamaCapabilities(caps);
if (ollamaModelsList) setOllamaModels(ollamaModelsList.map(m => ({ id: m.id, name: m.name })));
} else {
setOllamaModels([]);
}
}
} catch (error) {
console.error('Failed to toggle Ollama:', error);
}
};
const handleOllamaCapabilityToggle = async (modelId: string, field: 'tools' | 'vision', value: boolean) => {
const current = ollamaCapabilities[modelId] ?? { tools: false, vision: false };
const updated = { ...current, [field]: value };
try {
const result = await window.electronAPI?.chat.setOllamaModelCapabilities(modelId, updated);
if (result?.success) {
setOllamaCapabilities(prev => ({ ...prev, [modelId]: updated }));
// Refresh available models to reflect vision change
const modelsResult = await window.electronAPI?.chat.getAvailableModels();
if (modelsResult?.success && modelsResult.models) {
setAvailableModels(modelsResult.models);
}
}
} catch (error) {
console.error('Failed to update Ollama model capabilities:', error);
}
};
const handleTitleModelChange = async (modelId: string) => {
try {
const result = await window.electronAPI?.chat.setTitleModel(modelId);
@@ -1236,6 +1302,7 @@ export const SettingsView: React.FC = () => {
const providerLabel = (provider: string) => {
if (provider === 'anthropic' || provider === 'openai' || provider === 'google' || provider === 'other') return t('settings.ai.providerOpenCode');
if (provider === 'mistral') return t('settings.ai.providerMistral');
if (provider === 'ollama') return t('settings.ai.providerOllama');
return provider;
};
@@ -1346,17 +1413,76 @@ export const SettingsView: React.FC = () => {
)}
</SettingRow>
<SettingRow
id="ai-ollama"
label={t('settings.ai.ollamaLabel')}
description={t('settings.ai.ollamaDescription')}
>
<div className="setting-input-group">
<label className="toggle-label">
<input
id="ai-ollama"
type="checkbox"
checked={ollamaEnabled}
onChange={(e) => handleOllamaToggle(e.target.checked)}
/>
{t('settings.ai.ollamaEnable')}
</label>
{ollamaEnabled && (
<span className="setting-status-badge success">{t('settings.ai.configured')}</span>
)}
</div>
{ollamaEnabled && ollamaModels.length > 0 && (
<div className="ollama-model-capabilities">
<small className="setting-description">{t('settings.ai.ollamaCapabilitiesDescription')}</small>
<table className="ollama-caps-table">
<thead>
<tr>
<th>{t('settings.ai.ollamaCapModel')}</th>
<th>{t('settings.ai.ollamaCapTools')}</th>
<th>{t('settings.ai.ollamaCapVision')}</th>
</tr>
</thead>
<tbody>
{ollamaModels.map(m => {
const caps = ollamaCapabilities[m.id] ?? { tools: false, vision: false };
return (
<tr key={m.id}>
<td>{m.name}</td>
<td>
<input
type="checkbox"
checked={caps.tools}
onChange={(e) => handleOllamaCapabilityToggle(m.id, 'tools', e.target.checked)}
/>
</td>
<td>
<input
type="checkbox"
checked={caps.vision}
onChange={(e) => handleOllamaCapabilityToggle(m.id, 'vision', e.target.checked)}
/>
</td>
</tr>
);
})}
</tbody>
</table>
</div>
)}
</SettingRow>
<SettingRow
id="ai-model"
label={t('settings.ai.defaultModelLabel')}
description={t('settings.ai.defaultModelDescription')}
>
<div className="setting-input-group">
{renderModelSelect('ai-model', selectedModel, handleModelChange, !aiHasApiKey && !aiHasMistralKey)}
{renderModelSelect('ai-model', selectedModel, handleModelChange, !aiHasApiKey && !aiHasMistralKey && !ollamaEnabled)}
<button
className="secondary"
onClick={handleRefreshModelCatalog}
disabled={refreshingCatalog || (!aiHasApiKey && !aiHasMistralKey)}
disabled={refreshingCatalog || (!aiHasApiKey && !aiHasMistralKey && !ollamaEnabled)}
title={t('settings.ai.refreshModelCatalog')}
>
{refreshingCatalog ? t('settings.ai.refreshing') : t('settings.ai.refreshModelCatalog')}
@@ -1388,7 +1514,7 @@ export const SettingsView: React.FC = () => {
label={t('settings.ai.titleModelLabel')}
description={t('settings.ai.titleModelDescription')}
>
{renderModelSelect('ai-title-model', titleModel, handleTitleModelChange, !aiHasApiKey && !aiHasMistralKey)}
{renderModelSelect('ai-title-model', titleModel, handleTitleModelChange, !aiHasApiKey && !aiHasMistralKey && !ollamaEnabled)}
</SettingRow>
<SettingRow
@@ -1396,7 +1522,7 @@ export const SettingsView: React.FC = () => {
label={t('settings.ai.imageAnalysisModelLabel')}
description={t('settings.ai.imageAnalysisModelDescription')}
>
{renderModelSelect('ai-image-analysis-model', imageAnalysisModel, handleImageAnalysisModelChange, !aiHasApiKey && !aiHasMistralKey, groupedVisionModels)}
{renderModelSelect('ai-image-analysis-model', imageAnalysisModel, handleImageAnalysisModelChange, !aiHasApiKey && !aiHasMistralKey && !ollamaEnabled, groupedVisionModels)}
</SettingRow>
<SettingRow

View File

@@ -741,11 +741,21 @@
"settings.ai.imageAnalysisModelDescription": "Modell für die automatische Bildanalyse (Titel, Alt-Text, Bildunterschrift).",
"settings.ai.providerOpenCode": "OpenCode",
"settings.ai.providerMistral": "Mistral",
"settings.ai.providerOllama": "Ollama (Lokal)",
"settings.ai.providerOther": "Andere",
"settings.ai.ollamaLabel": "Ollama (Lokale Modelle)",
"settings.ai.ollamaDescription": "Verbinde dich mit einer lokal laufenden Ollama-Instanz, um lokale KI-Modelle zu verwenden.",
"settings.ai.ollamaEnable": "Ollama aktivieren",
"settings.ai.ollamaCapabilitiesDescription": "Fähigkeiten für jedes Ollama-Modell konfigurieren. Tools für Funktionsaufrufe oder Vision für Bildanalyse aktivieren.",
"settings.ai.ollamaCapModel": "Modell",
"settings.ai.ollamaCapTools": "Tools",
"settings.ai.ollamaCapVision": "Vision",
"chat.providerKeyMissing": "Das Modell '{{model}}' benötigt einen {{provider}} API-Schlüssel. Konfiguriere ihn in den Einstellungen.",
"settings.toast.modelCatalogRefreshed": "Modellkatalog aktualisiert ({{count}} Modelle)",
"settings.toast.modelCatalogUpToDate": "Modellkatalog ist bereits aktuell",
"settings.toast.modelCatalogRefreshFailed": "Modellkatalog konnte nicht aktualisiert werden",
"settings.toast.ollamaEnabled": "Ollama aktiviert",
"settings.toast.ollamaDisabled": "Ollama deaktiviert",
"settings.publishing.sshHostDescription": "Hostname oder IP-Adresse des SSH-Servers.",
"settings.publishing.sshUsernameDescription": "Benutzername deines SSH-Kontos.",
"settings.publishing.sshRemotePathDescription": "Das Zielverzeichnis auf dem Remote-Server, in das dein Blog veröffentlicht wird.",

View File

@@ -741,11 +741,21 @@
"settings.ai.imageAnalysisModelDescription": "Model used for automatic image analysis (title, alt text, caption).",
"settings.ai.providerOpenCode": "OpenCode",
"settings.ai.providerMistral": "Mistral",
"settings.ai.providerOllama": "Ollama (Local)",
"settings.ai.providerOther": "Other",
"settings.ai.ollamaLabel": "Ollama (Local Models)",
"settings.ai.ollamaDescription": "Connect to a locally running Ollama instance to use local AI models.",
"settings.ai.ollamaEnable": "Enable Ollama",
"settings.ai.ollamaCapabilitiesDescription": "Configure capabilities for each Ollama model. Enable tools for function calling or vision for image analysis.",
"settings.ai.ollamaCapModel": "Model",
"settings.ai.ollamaCapTools": "Tools",
"settings.ai.ollamaCapVision": "Vision",
"chat.providerKeyMissing": "The model '{{model}}' requires a {{provider}} API key. Configure it in Settings.",
"settings.toast.modelCatalogRefreshed": "Model catalog updated ({{count}} models)",
"settings.toast.modelCatalogUpToDate": "Model catalog already up to date",
"settings.toast.modelCatalogRefreshFailed": "Failed to refresh model catalog",
"settings.toast.ollamaEnabled": "Ollama enabled",
"settings.toast.ollamaDisabled": "Ollama disabled",
"settings.publishing.sshHostDescription": "The SSH server hostname or IP address.",
"settings.publishing.sshUsernameDescription": "Your SSH account username.",
"settings.publishing.sshRemotePathDescription": "The destination directory on the remote server where your blog will be published.",

View File

@@ -741,11 +741,21 @@
"settings.ai.imageAnalysisModelDescription": "Modelo utilizado para el análisis automático de imágenes (título, texto alternativo, leyenda).",
"settings.ai.providerOpenCode": "OpenCode",
"settings.ai.providerMistral": "Mistral",
"settings.ai.providerOllama": "Ollama (Local)",
"settings.ai.providerOther": "Otro",
"settings.ai.ollamaLabel": "Ollama (Modelos locales)",
"settings.ai.ollamaDescription": "Conéctate a una instancia local de Ollama para usar modelos de IA locales.",
"settings.ai.ollamaEnable": "Activar Ollama",
"settings.ai.ollamaCapabilitiesDescription": "Configurar las capacidades de cada modelo Ollama. Activar herramientas para llamadas a funciones o visión para análisis de imágenes.",
"settings.ai.ollamaCapModel": "Modelo",
"settings.ai.ollamaCapTools": "Herramientas",
"settings.ai.ollamaCapVision": "Visión",
"chat.providerKeyMissing": "El modelo '{{model}}' requiere una clave API de {{provider}}. Configúrela en Ajustes.",
"settings.toast.modelCatalogRefreshed": "Catálogo actualizado ({{count}} modelos)",
"settings.toast.modelCatalogUpToDate": "El catálogo ya está actualizado",
"settings.toast.modelCatalogRefreshFailed": "No se pudo actualizar el catálogo",
"settings.toast.ollamaEnabled": "Ollama activado",
"settings.toast.ollamaDisabled": "Ollama desactivado",
"settings.publishing.sshHostDescription": "Nombre de host o IP del servidor SSH.",
"settings.publishing.sshUsernameDescription": "Nombre de usuario de SSH.",
"settings.publishing.sshRemotePathDescription": "El directorio de destino en el servidor remoto donde se publicará tu blog.",

View File

@@ -739,11 +739,21 @@
"settings.ai.imageAnalysisModelDescription": "Modèle utilisé pour l'analyse automatique d'images (titre, texte alternatif, légende).",
"settings.ai.providerOpenCode": "OpenCode",
"settings.ai.providerMistral": "Mistral",
"settings.ai.providerOllama": "Ollama (Local)",
"settings.ai.providerOther": "Autre",
"settings.ai.ollamaLabel": "Ollama (Modèles locaux)",
"settings.ai.ollamaDescription": "Connectez-vous à une instance Ollama locale pour utiliser des modèles d'IA locaux.",
"settings.ai.ollamaEnable": "Activer Ollama",
"settings.ai.ollamaCapabilitiesDescription": "Configurer les capacités de chaque modèle Ollama. Activer les outils pour les appels de fonctions ou la vision pour l'analyse d'images.",
"settings.ai.ollamaCapModel": "Modèle",
"settings.ai.ollamaCapTools": "Outils",
"settings.ai.ollamaCapVision": "Vision",
"chat.providerKeyMissing": "Le modèle '{{model}}' nécessite une clé API {{provider}}. Configurez-la dans les paramètres.",
"settings.toast.modelCatalogRefreshed": "Catalogue mis à jour ({{count}} modèles)",
"settings.toast.modelCatalogUpToDate": "Le catalogue est déjà à jour",
"settings.toast.modelCatalogRefreshFailed": "Échec de l'actualisation du catalogue",
"settings.toast.ollamaEnabled": "Ollama activé",
"settings.toast.ollamaDisabled": "Ollama désactivé",
"settings.publishing.sshHostDescription": "Nom d'hôte ou IP du serveur SSH.",
"settings.publishing.sshUsernameDescription": "Nom d'utilisateur SSH.",
"settings.publishing.sshRemotePathDescription": "Le répertoire de destination sur le serveur distant où votre blog sera publié.",

View File

@@ -739,11 +739,21 @@
"settings.ai.imageAnalysisModelDescription": "Modello utilizzato per l'analisi automatica delle immagini (titolo, testo alternativo, didascalia).",
"settings.ai.providerOpenCode": "OpenCode",
"settings.ai.providerMistral": "Mistral",
"settings.ai.providerOllama": "Ollama (Locale)",
"settings.ai.providerOther": "Altro",
"settings.ai.ollamaLabel": "Ollama (Modelli locali)",
"settings.ai.ollamaDescription": "Connettiti a un'istanza Ollama locale per utilizzare modelli IA locali.",
"settings.ai.ollamaEnable": "Attiva Ollama",
"settings.ai.ollamaCapabilitiesDescription": "Configura le capacità per ogni modello Ollama. Attiva gli strumenti per le chiamate a funzioni o la visione per l'analisi delle immagini.",
"settings.ai.ollamaCapModel": "Modello",
"settings.ai.ollamaCapTools": "Strumenti",
"settings.ai.ollamaCapVision": "Visione",
"chat.providerKeyMissing": "Il modello '{{model}}' richiede una chiave API {{provider}}. Configurala nelle Impostazioni.",
"settings.toast.modelCatalogRefreshed": "Catalogo aggiornato ({{count}} modelli)",
"settings.toast.modelCatalogUpToDate": "Il catalogo è già aggiornato",
"settings.toast.modelCatalogRefreshFailed": "Aggiornamento del catalogo non riuscito",
"settings.toast.ollamaEnabled": "Ollama attivato",
"settings.toast.ollamaDisabled": "Ollama disattivato",
"settings.publishing.sshHostDescription": "Hostname o IP del server SSH.",
"settings.publishing.sshUsernameDescription": "Nome utente SSH.",
"settings.publishing.sshRemotePathDescription": "La directory di destinazione sul server remoto in cui verrà pubblicato il tuo blog.",