Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

feat(ai): let every provider point at a custom server

Luis Ortiz448a1ea3f64c
diff --git a/src/core/capture/ai/__tests__/models.test.ts b/src/core/capture/ai/__tests__/models.test.ts
index 98286a2..37d2a6f 100644
--- a/src/core/capture/ai/__tests__/models.test.ts
+++ b/src/core/capture/ai/__tests__/models.test.ts
@@ -1,7 +1,15 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
-import { AI_PROVIDERS, CUSTOM_MODEL_VALUE, isCustomModel } from '../models';
+import {
+ AI_PROVIDERS,
+ CUSTOM_MODEL_VALUE,
+ findProvider,
+ isCustomBaseUrl,
+ isCustomModel,
+ isProviderKey,
+ resolveBaseUrl,
+} from '../models';
const LOCALES = ['en', 'de', 'es', 'fr', 'pt-BR', 'zh-CN'];
@@ -61,24 +69,65 @@ describe('every provider default is selectable', () => {
});
});
-describe('OpenAI provider has base URL support', () => {
- it('opts into a base URL', () => {
- const config = AI_PROVIDERS.openai;
- expect(config.baseUrl).toBe(true);
+describe('every provider takes a custom server', () => {
+ it.each(Object.entries(AI_PROVIDERS))('%s carries a default base URL and a protocol', (_key, config) => {
+ expect(config.defaultBaseUrl).toMatch(/^https:\/\//);
+ expect(['openai', 'anthropic']).toContain(config.protocol);
});
- it('carries the base URL label in every locale', () => {
+ it('carries the custom server copy in every locale', () => {
for (const locale of LOCALES) {
- expect(localeKeys(locale).has('settings.baseUrl')).toBe(true);
+ const keys = localeKeys(locale);
+ expect(keys.has('settings.baseUrl')).toBe(true);
+ expect(keys.has('settings.useOwnServer')).toBe(true);
+ expect(keys.has('settings.ownServerHintOpenai')).toBe(true);
+ expect(keys.has('settings.ownServerHintAnthropic')).toBe(true);
}
});
+ it('no longer offers a second OpenAI entry', () => {
+ expect(Object.keys(AI_PROVIDERS)).toEqual(['openai', 'anthropic', 'deepseek']);
+ });
+
it('includes a Custom model option', () => {
const config = AI_PROVIDERS.openai;
expect(config.models.some((m) => m.id === CUSTOM_MODEL_VALUE)).toBe(true);
});
});
+describe('custom base URL detection', () => {
+ it('reads a blank or default URL as not custom', () => {
+ expect(isCustomBaseUrl(AI_PROVIDERS.openai, '')).toBe(false);
+ expect(isCustomBaseUrl(AI_PROVIDERS.openai, undefined)).toBe(false);
+ expect(isCustomBaseUrl(AI_PROVIDERS.openai, 'https://api.openai.com/v1')).toBe(false);
+ expect(isCustomBaseUrl(AI_PROVIDERS.openai, 'https://api.openai.com/v1/')).toBe(false);
+ });
+
+ it('reads another host as custom, per provider', () => {
+ expect(isCustomBaseUrl(AI_PROVIDERS.openai, 'http://localhost:11434/v1')).toBe(true);
+ expect(isCustomBaseUrl(AI_PROVIDERS.anthropic, 'http://localhost:4000')).toBe(true);
+ expect(isCustomBaseUrl(AI_PROVIDERS.deepseek, 'https://api.deepseek.com')).toBe(false);
+ });
+
+ it('resolves to the provider default when nothing is set', () => {
+ expect(resolveBaseUrl(AI_PROVIDERS.deepseek)).toBe('https://api.deepseek.com');
+ expect(resolveBaseUrl(AI_PROVIDERS.anthropic, ' ')).toBe('https://api.anthropic.com/v1');
+ expect(resolveBaseUrl(AI_PROVIDERS.openai, 'http://localhost:8787/v1/')).toBe('http://localhost:8787/v1');
+ });
+});
+
+describe('stored provider keys', () => {
+ it('rejects a provider that no longer exists', () => {
+ expect(isProviderKey('openaiCompatible')).toBe(false);
+ expect(findProvider('openaiCompatible')).toBeUndefined();
+ });
+
+ it('accepts the ones that do', () => {
+ expect(isProviderKey('openai')).toBe(true);
+ expect(findProvider('deepseek')).toBe(AI_PROVIDERS.deepseek);
+ });
+});
+
describe('model picker copy', () => {
it.each(LOCALES)('%s carries every key the model picker renders', (locale) => {
const keys = localeKeys(locale);
diff --git a/src/core/capture/ai/__tests__/validate.test.ts b/src/core/capture/ai/__tests__/validate.test.ts
index 3a34f41..4cbbb37 100644
--- a/src/core/capture/ai/__tests__/validate.test.ts
+++ b/src/core/capture/ai/__tests__/validate.test.ts
@@ -209,4 +209,66 @@ describe('validateApiKey', () => {
});
});
});
+
+ describe('a custom server on any provider', () => {
+ it('probes an openai-protocol server at chat/completions with a bearer token', async () => {
+ fetchMock.mockResolvedValueOnce(chatOkBody());
+ fetchMock.mockResolvedValueOnce(modelsBody('mock-tiny'));
+ await validateApiKey('openai', 'sk-key', 'http://localhost:8787/v1', 'mock-tiny');
+ const [url, init] = fetchMock.mock.calls[0];
+ expect(url).toBe('http://localhost:8787/v1/chat/completions');
+ expect((init!.headers as Record<string, string>).Authorization).toBe('Bearer sk-key');
+ });
+
+ it('probes an anthropic-protocol server at messages with an x-api-key', async () => {
+ fetchMock.mockResolvedValueOnce(chatOkBody());
+ fetchMock.mockResolvedValueOnce(modelsBody('claude-local'));
+ expect(await validateApiKey('anthropic', 'ak-key', 'http://localhost:4000', 'claude-local')).toEqual({
+ valid: true,
+ models: ['claude-local'],
+ });
+ const [url, init] = fetchMock.mock.calls[0];
+ expect(url).toBe('http://localhost:4000/messages');
+ const headers = init!.headers as Record<string, string>;
+ expect(headers['x-api-key']).toBe('ak-key');
+ expect(headers.Authorization).toBeUndefined();
+ expect(JSON.parse(init!.body as string).max_tokens).toBe(8);
+ });
+
+ it('lets deepseek point somewhere else', async () => {
+ fetchMock.mockResolvedValueOnce(chatOkBody());
+ fetchMock.mockResolvedValueOnce(modelsBody('local-r1'));
+ expect(await validateApiKey('deepseek', 'sk-key', 'http://localhost:1234/v1', 'local-r1')).toEqual({
+ valid: true,
+ models: ['local-r1'],
+ });
+ expect(fetchMock.mock.calls[0][0]).toBe('http://localhost:1234/v1/chat/completions');
+ });
+
+ it('treats a provider default typed in by hand as the default, not a custom server', async () => {
+ fetchMock.mockResolvedValueOnce(modelsBody('deepseek-v4-flash'));
+ expect(await validateApiKey('deepseek', 'sk-key', 'https://api.deepseek.com/', 'deepseek-v4-flash')).toEqual({
+ valid: true,
+ models: ['deepseek-v4-flash'],
+ });
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(fetchMock.mock.calls[0][0]).toBe('https://api.deepseek.com/models');
+ });
+
+ it('checks an anthropic key against anthropic by default', async () => {
+ fetchMock.mockResolvedValueOnce(modelsBody('claude-3-5-haiku-20241022'));
+ await validateApiKey('anthropic', 'ak-key');
+ const [url, init] = fetchMock.mock.calls[0];
+ expect(url).toBe('https://api.anthropic.com/v1/models');
+ expect((init!.headers as Record<string, string>)['anthropic-version']).toBe('2023-06-01');
+ });
+
+ it('no longer knows the removed compatible provider, and sends it no key', async () => {
+ expect(await validateApiKey('openaiCompatible', 'sk-key', 'http://localhost:8787/v1', 'mock-tiny')).toEqual({
+ valid: false,
+ reason: 'network',
+ });
+ expect(fetchMock).not.toHaveBeenCalled();
+ });
+ });
});
diff --git a/src/core/capture/ai/models.ts b/src/core/capture/ai/models.ts
index 23a33a0..47fc1d2 100644
--- a/src/core/capture/ai/models.ts
+++ b/src/core/capture/ai/models.ts
@@ -3,22 +3,28 @@ export interface AIModelOption {
label: string;
}
-export const DEFAULT_OPENAI_BASE_URL = 'https://api.openai.com/v1';
+export type AIProtocol = 'openai' | 'anthropic';
+
+export type OpenAITransport = 'responses' | 'chat';
export interface AIProviderConfig {
label: string;
+ protocol: AIProtocol;
+ transport?: OpenAITransport;
+ defaultBaseUrl: string;
defaultModel: string;
models: AIModelOption[];
- baseUrl?: boolean;
}
export const CUSTOM_MODEL_VALUE = 'mimik-custom-model';
-export const AI_PROVIDERS: Record<string, AIProviderConfig> = {
+export const AI_PROVIDERS = {
openai: {
label: 'OpenAI',
+ protocol: 'openai',
+ transport: 'responses',
+ defaultBaseUrl: 'https://api.openai.com/v1',
defaultModel: 'gpt-4o-mini',
- baseUrl: true,
models: [
{ id: 'gpt-4o-mini', label: 'GPT-4o Mini' },
{ id: 'gpt-4.1-nano', label: 'GPT-4.1 Nano' },
@@ -30,6 +36,8 @@ export const AI_PROVIDERS: Record<string, AIProviderConfig> = {
},
anthropic: {
label: 'Anthropic',
+ protocol: 'anthropic',
+ defaultBaseUrl: 'https://api.anthropic.com/v1',
defaultModel: 'claude-3-5-haiku-20241022',
models: [
{ id: 'claude-3-5-haiku-20241022', label: 'Claude 3.5 Haiku' },
@@ -37,14 +45,11 @@ export const AI_PROVIDERS: Record<string, AIProviderConfig> = {
{ id: CUSTOM_MODEL_VALUE, label: 'Custom' },
],
},
- openaiCompatible: {
- label: 'OpenAI Compatible',
- defaultModel: 'gpt-4o-mini',
- models: [],
- baseUrl: true,
- },
deepseek: {
label: 'DeepSeek',
+ protocol: 'openai',
+ transport: 'chat',
+ defaultBaseUrl: 'https://api.deepseek.com',
defaultModel: 'deepseek-v4-flash',
models: [
{ id: 'deepseek-v4-flash', label: 'DeepSeek V4 Flash' },
@@ -53,10 +58,42 @@ export const AI_PROVIDERS: Record<string, AIProviderConfig> = {
{ id: CUSTOM_MODEL_VALUE, label: 'Custom' },
],
},
-};
+} satisfies Record<string, AIProviderConfig>;
export type AIProviderKey = keyof typeof AI_PROVIDERS;
+export const DEFAULT_AI_PROVIDER: AIProviderKey = 'openai';
+
+export function isProviderKey(value: unknown): value is AIProviderKey {
+ return typeof value === 'string' && value in AI_PROVIDERS;
+}
+
+export function findProvider(provider: string): AIProviderConfig | undefined {
+ return isProviderKey(provider) ? AI_PROVIDERS[provider] : undefined;
+}
+
+export function providerOrDefault(value: unknown): AIProviderKey {
+ return isProviderKey(value) ? value : DEFAULT_AI_PROVIDER;
+}
+
+export function normalizeBaseUrl(url: string): string {
+ return url.trim().replace(/\/+$/, '');
+}
+
+export function resolveBaseUrl(config: AIProviderConfig, baseUrl?: string): string {
+ return normalizeBaseUrl(baseUrl?.trim() || config.defaultBaseUrl);
+}
+
+export function isCustomBaseUrl(config: AIProviderConfig, baseUrl?: string): boolean {
+ const trimmed = baseUrl?.trim();
+ if (!trimmed) return false;
+ return normalizeBaseUrl(trimmed) !== normalizeBaseUrl(config.defaultBaseUrl);
+}
+
+export function openAITransport(config: AIProviderConfig, baseUrl?: string): OpenAITransport {
+ return isCustomBaseUrl(config, baseUrl) ? 'chat' : (config.transport ?? 'chat');
+}
+
export function isCustomModel(model: string, provider: AIProviderConfig): boolean {
const id = model.trim();
return id.length > 0 && !provider.models.some((option) => option.id === id);
diff --git a/src/core/capture/ai/provider.ts b/src/core/capture/ai/provider.ts
index e6c1284..aef3d23 100644
--- a/src/core/capture/ai/provider.ts
+++ b/src/core/capture/ai/provider.ts
@@ -1,14 +1,11 @@
import { createAnthropic } from '@ai-sdk/anthropic';
import { createOpenAI } from '@ai-sdk/openai';
-
-const DEEPSEEK_BASE_URL = 'https://api.deepseek.com';
+import { AI_PROVIDERS, DEFAULT_AI_PROVIDER, findProvider, openAITransport, resolveBaseUrl } from './models';
export function createModel(provider: string, model: string, apiKey: string, baseUrl?: string) {
- if (provider === 'anthropic') return createAnthropic({ apiKey })(model);
- if (provider === 'openaiCompatible') {
- const baseURL = baseUrl?.trim();
- return createOpenAI(baseURL ? { apiKey, baseURL } : { apiKey })(model);
- }
- if (provider === 'deepseek') return createOpenAI({ apiKey, baseURL: DEEPSEEK_BASE_URL, name: 'deepseek' })(model);
- return createOpenAI({ apiKey })(model);
+ const config = findProvider(provider) ?? AI_PROVIDERS[DEFAULT_AI_PROVIDER];
+ const baseURL = resolveBaseUrl(config, baseUrl);
+ if (config.protocol === 'anthropic') return createAnthropic({ apiKey, baseURL })(model);
+ const openai = createOpenAI({ apiKey, baseURL, name: provider });
+ return openAITransport(config, baseUrl) === 'responses' ? openai(model) : openai.chat(model);
}
diff --git a/src/core/capture/ai/rewrite.ts b/src/core/capture/ai/rewrite.ts
index ea99cb7..160ecc8 100644
--- a/src/core/capture/ai/rewrite.ts
+++ b/src/core/capture/ai/rewrite.ts
@@ -2,7 +2,7 @@ import { generateText } from 'ai';
import { localStorage } from '@/lib/browser-api';
import { logger } from '@/lib/logger';
import type { RewriteSelectionResponse } from '@/lib/messaging';
-import { AI_PROVIDERS } from './models';
+import { AI_PROVIDERS, providerOrDefault } from './models';
import { getLanguageSuffix, REWRITE_PROMPT } from './prompts';
import { createModel } from './provider';
@@ -25,7 +25,7 @@ export async function rewriteSelection(text: string, instruction: string): Promi
const settings = await localStorage.get(['aiApiKey', 'aiProvider', 'aiModel', 'aiBaseUrl', 'aiLanguage']);
if (!settings.aiApiKey) return { error: 'no-api-key' };
- const provider = (settings.aiProvider as string) || 'openai';
+ const provider = providerOrDefault(settings.aiProvider);
try {
const { text: raw } = await generateText({
diff --git a/src/core/capture/ai/validate.ts b/src/core/capture/ai/validate.ts
index fc8fae0..bc4e367 100644
--- a/src/core/capture/ai/validate.ts
+++ b/src/core/capture/ai/validate.ts
@@ -1,5 +1,12 @@
import { logger } from '@/lib/logger';
-import { DEFAULT_OPENAI_BASE_URL } from './models';
+import {
+ type AIProtocol,
+ type AIProviderConfig,
+ findProvider,
+ isCustomBaseUrl,
+ normalizeBaseUrl,
+ resolveBaseUrl,
+} from './models';
export type KeyValidation =
| { valid: true; models?: string[] }
@@ -7,36 +14,20 @@ export type KeyValidation =
const REQUEST_TIMEOUT_MS = 10_000;
-function normalizeUrl(url: string): string {
- return url.trim().replace(/\/+$/, '');
-}
-
-function isOpenAIEndpoint(baseUrl?: string): boolean {
- if (!baseUrl?.trim()) return true;
- return normalizeUrl(baseUrl) === normalizeUrl(DEFAULT_OPENAI_BASE_URL);
-}
+const PROTOCOL_HEADERS: Record<AIProtocol, (key: string) => Record<string, string>> = {
+ openai: (key) => ({ Authorization: `Bearer ${key}` }),
+ anthropic: (key) => ({
+ 'x-api-key': key,
+ 'anthropic-version': '2023-06-01',
+ 'anthropic-dangerous-direct-browser-access': 'true',
+ }),
+};
-const ENDPOINTS: Record<string, { url?: string; headers: (key: string) => Record<string, string> }> = {
- openai: {
- url: 'https://api.openai.com/v1/models',
- headers: (key) => ({ Authorization: `Bearer ${key}` }),
- },
- anthropic: {
- url: 'https://api.anthropic.com/v1/models',
- headers: (key) => ({
- 'x-api-key': key,
- 'anthropic-version': '2023-06-01',
- 'anthropic-dangerous-direct-browser-access': 'true',
- }),
- },
+const VOICE_ENDPOINTS: Record<string, { url: string; headers: (key: string) => Record<string, string> }> = {
groq: {
url: 'https://api.groq.com/openai/v1/models',
headers: (key) => ({ Authorization: `Bearer ${key}` }),
},
- deepseek: {
- url: 'https://api.deepseek.com/models',
- headers: (key) => ({ Authorization: `Bearer ${key}` }),
- },
};
function parseModelIds(body: unknown): string[] | undefined {
@@ -63,22 +54,41 @@ async function fetchModelsFromUrl(url: string, headers: Record<string, string>):
}
}
-async function probeWithChatCompletion(
+async function checkCatalog(url: string, headers: Record<string, string>): Promise<KeyValidation> {
+ try {
+ const res = await fetch(url, {
+ headers,
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
+ });
+ if (res.ok) {
+ const models = parseModelIds(await res.json().catch(() => null));
+ return models ? { valid: true, models } : { valid: true };
+ }
+ if (res.status === 401 || res.status === 403) return { valid: false, reason: 'rejected' };
+ return { valid: false, reason: 'network' };
+ } catch (err) {
+ logger.error('API key validation request failed', err);
+ return { valid: false, reason: 'network' };
+ }
+}
+
+async function probeWithInference(
+ protocol: AIProtocol,
baseUrl: string,
model: string,
headers: Record<string, string>,
): Promise<boolean> {
+ const base = normalizeBaseUrl(baseUrl);
+ const url = protocol === 'anthropic' ? `${base}/messages` : `${base}/chat/completions`;
+ const body =
+ protocol === 'anthropic'
+ ? { model, max_tokens: 8, messages: [{ role: 'user', content: 'Reply with OK.' }] }
+ : { model, messages: [{ role: 'user', content: 'Reply with OK.' }], max_tokens: 8, stream: false };
try {
- const chatUrl = `${normalizeUrl(baseUrl)}/chat/completions`;
- const res = await fetch(chatUrl, {
+ const res = await fetch(url, {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
- body: JSON.stringify({
- model,
- messages: [{ role: 'user', content: 'Reply with OK.' }],
- max_tokens: 8,
- stream: false,
- }),
+ body: JSON.stringify(body),
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
});
return res.ok;
@@ -87,60 +97,50 @@ async function probeWithChatCompletion(
}
}
-export async function validateApiKey(
- provider: string,
+async function validateCustomServer(
+ config: AIProviderConfig,
apiKey: string,
- baseUrl?: string,
+ baseUrl: string,
model?: string,
): Promise<KeyValidation> {
- if (provider === 'openai' && !isOpenAIEndpoint(baseUrl)) {
- const trimmedBase = baseUrl?.trim();
- if (!trimmedBase) {
- logger.error('OpenAI provider with no base URL');
- return { valid: false, reason: 'network' };
- }
-
- const headers = { Authorization: `Bearer ${apiKey}` };
-
- const selectedModel = model?.trim();
- if (!selectedModel) {
- const models = await fetchModelsFromUrl(`${normalizeUrl(trimmedBase)}/models`, headers);
- return models ? { valid: false, reason: 'model-required', models } : { valid: false, reason: 'model-required' };
- }
+ const headers = PROTOCOL_HEADERS[config.protocol](apiKey);
+ const base = normalizeBaseUrl(baseUrl);
+ const catalogUrl = `${base}/models`;
- const probeOk = await probeWithChatCompletion(trimmedBase, selectedModel, headers);
- if (!probeOk) {
- const models = await fetchModelsFromUrl(`${normalizeUrl(trimmedBase)}/models`, headers);
- if (models && !models.includes(selectedModel)) {
- return { valid: false, reason: 'model-invalid', models };
- }
- return { valid: false, reason: 'rejected' };
- }
+ const selectedModel = model?.trim();
+ if (!selectedModel) {
+ const models = await fetchModelsFromUrl(catalogUrl, headers);
+ return models ? { valid: false, reason: 'model-required', models } : { valid: false, reason: 'model-required' };
+ }
- const models = await fetchModelsFromUrl(`${normalizeUrl(trimmedBase)}/models`, headers);
+ if (await probeWithInference(config.protocol, base, selectedModel, headers)) {
+ const models = await fetchModelsFromUrl(catalogUrl, headers);
return models ? { valid: true, models } : { valid: true };
}
- const endpoint = ENDPOINTS[provider];
- const url = endpoint?.url ?? null;
- if (!url) {
- logger.error('No API key validation endpoint for provider', provider);
- return { valid: false, reason: 'network' };
- }
- try {
- const res = await fetch(url, {
- headers: endpoint.headers(apiKey),
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
- });
- if (res.ok) {
- const body = await res.json().catch(() => null);
- const models = parseModelIds(body);
- return models ? { valid: true, models } : { valid: true };
+ const models = await fetchModelsFromUrl(catalogUrl, headers);
+ if (models && !models.includes(selectedModel)) return { valid: false, reason: 'model-invalid', models };
+ return { valid: false, reason: 'rejected' };
+}
+
+export async function validateApiKey(
+ provider: string,
+ apiKey: string,
+ baseUrl?: string,
+ model?: string,
+): Promise<KeyValidation> {
+ const config = findProvider(provider);
+
+ if (!config) {
+ const endpoint = VOICE_ENDPOINTS[provider];
+ if (!endpoint) {
+ logger.error('No API key validation endpoint for provider', provider);
+ return { valid: false, reason: 'network' };
}
- if (res.status === 401 || res.status === 403) return { valid: false, reason: 'rejected' };
- return { valid: false, reason: 'network' };
- } catch (err) {
- logger.error('API key validation request failed', err);
- return { valid: false, reason: 'network' };
+ return checkCatalog(endpoint.url, endpoint.headers(apiKey));
}
+
+ if (isCustomBaseUrl(config, baseUrl)) return validateCustomServer(config, apiKey, baseUrl as string, model);
+
+ return checkCatalog(`${resolveBaseUrl(config)}/models`, PROTOCOL_HEADERS[config.protocol](apiKey));
}
diff --git a/src/core/guides/types.ts b/src/core/guides/types.ts
index f7f874a..a95f87d 100644
--- a/src/core/guides/types.ts
+++ b/src/core/guides/types.ts
@@ -1,3 +1,4 @@
+import type { AIProviderKey } from '@/core/capture/ai/models';
import type { VoiceProvider } from '@/core/capture/voice/transcribe';
import type { ScreenshotEdits } from '@/core/screenshot/types';
@@ -59,7 +60,7 @@ export interface Screenshot {
export interface Settings {
aiApiKey: string;
- aiProvider: 'openai' | 'anthropic' | 'openaiCompatible' | 'deepseek';
+ aiProvider: AIProviderKey;
aiModel: string;
aiBaseUrl?: string;
voiceEnabled: boolean;
diff --git a/src/entrypoints/background/guide-meta.ts b/src/entrypoints/background/guide-meta.ts
index edfce89..decf3ff 100644
--- a/src/entrypoints/background/guide-meta.ts
+++ b/src/entrypoints/background/guide-meta.ts
@@ -1,6 +1,6 @@
import { i18n } from '#imports';
import { generateGuideMeta } from '@/core/capture/ai/meta';
-import { AI_PROVIDERS } from '@/core/capture/ai/models';
+import { AI_PROVIDERS, providerOrDefault } from '@/core/capture/ai/models';
import { actionSteps } from '@/core/guides/blocks';
import {
clearStepAiPending,
@@ -36,7 +36,7 @@ async function resolveGuideMetaInputs(guideId: string): Promise<GuideMetaInputs>
const described = steps.filter((s) => s.description).map((s) => ({ description: s.description, url: s.url }));
if (described.length === 0) return { ok: false, reason: 'no-steps' };
- const provider = (settings.aiProvider as string) || 'openai';
+ const provider = providerOrDefault(settings.aiProvider);
return {
ok: true,
steps: described.length > 15 ? [...described.slice(0, 10), ...described.slice(-5)] : described,
diff --git a/src/locales/de.yml b/src/locales/de.yml
index a1c5318..01ee120 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -98,9 +98,14 @@ settings:
aiDescriptions: KI-Beschreibungen
modelCustom: Eigenes Modell
baseUrl: Basis-URL
+ useOwnServer: Eigenen Server verwenden
+ ownServerHintOpenai: "Funktioniert mit Ollama, LM Studio, vLLM oder jedem OpenAI-kompatiblen Server."
+ ownServerHintAnthropic: "Funktioniert mit einem LiteLLM-Proxy oder jedem Anthropic-kompatiblen Server."
provider: Anbieter
model: Modell
apiKey: API-Schlüssel
+ showKey: Schlüssel anzeigen
+ hideKey: Schlüssel verbergen
aiLanguage: Sprache der Beschreibungen
voiceNarration: Sprachkommentar
voiceUsingAiKey: "Es ist kein Sprach-Schlüssel gesetzt, daher nutzt Mimik den OpenAI-Schlüssel aus den KI-Beschreibungen oben."
diff --git a/src/locales/en.yml b/src/locales/en.yml
index 6c4e28d..9bf9511 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -88,7 +88,12 @@ settings:
model: Model
modelCustom: Custom model
baseUrl: Base URL
+ useOwnServer: Use my own server
+ ownServerHintOpenai: "Works with Ollama, LM Studio, vLLM, or any OpenAI-compatible server."
+ ownServerHintAnthropic: "Works with a LiteLLM proxy or any Anthropic-compatible server."
apiKey: API Key
+ showKey: Show key
+ hideKey: Hide key
aiLanguage: Description Language
voiceNarration: Voice Narration
voiceUsingAiKey: "No voice key is set, so Mimik uses the OpenAI key from AI Descriptions above."
diff --git a/src/locales/es.yml b/src/locales/es.yml
index 80fbe82..ca56156 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -88,7 +88,12 @@ settings:
model: Modelo
modelCustom: Modelo personalizado
baseUrl: URL base
+ useOwnServer: Usar mi propio servidor
+ ownServerHintOpenai: "Funciona con Ollama, LM Studio, vLLM o cualquier servidor compatible con OpenAI."
+ ownServerHintAnthropic: "Funciona con un proxy LiteLLM o cualquier servidor compatible con Anthropic."
apiKey: Clave API
+ showKey: Mostrar clave
+ hideKey: Ocultar clave
aiLanguage: Idioma de descripciones
voiceNarration: "Narración por voz"
voiceUsingAiKey: "No hay clave de voz, así que Mimik usa la clave de OpenAI de Descripciones con IA de arriba."
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index 1befa9f..b7ffabb 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -88,7 +88,12 @@ settings:
model: "Modèle"
modelCustom: Modèle personnalisé
baseUrl: URL de base
+ useOwnServer: Utiliser mon propre serveur
+ ownServerHintOpenai: "Fonctionne avec Ollama, LM Studio, vLLM ou tout serveur compatible OpenAI."
+ ownServerHintAnthropic: "Fonctionne avec un proxy LiteLLM ou tout serveur compatible Anthropic."
apiKey: "Clé API"
+ showKey: Afficher la clé
+ hideKey: Masquer la clé
aiLanguage: Langue des descriptions
voiceNarration: "Narration vocale"
voiceUsingAiKey: "Aucune clé vocale n'est définie : Mimik utilise la clé OpenAI des descriptions IA ci-dessus."
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index 0b0863c..dd464ca 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -88,7 +88,12 @@ settings:
model: Modelo
modelCustom: Modelo personalizado
baseUrl: URL base
+ useOwnServer: Usar meu próprio servidor
+ ownServerHintOpenai: "Funciona com Ollama, LM Studio, vLLM ou qualquer servidor compatível com OpenAI."
+ ownServerHintAnthropic: "Funciona com um proxy LiteLLM ou qualquer servidor compatível com Anthropic."
apiKey: Chave da API
+ showKey: Mostrar chave
+ hideKey: Ocultar chave
aiLanguage: "Idioma das descrições"
voiceNarration: "Narração por voz"
voiceUsingAiKey: "Não tem chave de voz, então o Mimik usa a chave da OpenAI das Descrições com IA lá de cima."
diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml
index 7aac147..934c678 100644
--- a/src/locales/zh-CN.yml
+++ b/src/locales/zh-CN.yml
@@ -88,7 +88,12 @@ settings:
model: 模型
modelCustom: 自定义模型
baseUrl: 基础 URL
+ useOwnServer: 使用自己的服务器
+ ownServerHintOpenai: "支持 Ollama、LM Studio、vLLM 或任何兼容 OpenAI 的服务器。"
+ ownServerHintAnthropic: "支持 LiteLLM 代理或任何兼容 Anthropic 的服务器。"
apiKey: API 密钥
+ showKey: 显示密钥
+ hideKey: 隐藏密钥
aiLanguage: 描述语言
voiceNarration: 语音讲解
voiceUsingAiKey: "未设置语音密钥,因此 Mimik 会使用上方 AI 描述中的 OpenAI 密钥。"