diff --git a/client/src/components/Settings/ai/aiConnectModel.test.ts b/client/src/components/Settings/ai/aiConnectModel.test.ts index eede6e392..42e95136f 100644 --- a/client/src/components/Settings/ai/aiConnectModel.test.ts +++ b/client/src/components/Settings/ai/aiConnectModel.test.ts @@ -47,6 +47,14 @@ describe('aiConnectModel', () => { expect(connectErrorKey(new Error('boom'))).toBe('assistant.error.generic'); }); + it('FE-AI-CONNECT-MODEL-002b: tells an own server that answered without a model list from one that is down (#2808)', () => { + const noList = { response: { data: { code: 'provider_unavailable', reason: 'no_model_list' } } }; + expect(connectErrorKey(noList)).toBe('assistant.connect.noModelList'); + expect(connectErrorKey({ response: { data: { code: 'provider_unavailable', reason: 'other' } } })).toBe( + 'assistant.error.providerDown' + ); + }); + it('FE-AI-CONNECT-MODEL-003: offers the way back into a broken connection, none for a working one', () => { expect(repairModeOf(VIEW)).toBeNull(); expect(repairModeOf({ ...VIEW, status: 'error' })).toBe('key'); diff --git a/client/src/components/Settings/ai/aiConnectModel.ts b/client/src/components/Settings/ai/aiConnectModel.ts index 4a7eb5137..e09f97dc1 100644 --- a/client/src/components/Settings/ai/aiConnectModel.ts +++ b/client/src/components/Settings/ai/aiConnectModel.ts @@ -33,9 +33,20 @@ const CONNECT_ERRORS: Record = { offline: { messageKey: 'assistant.error.offline' }, }; -/** The line a failed connect shows. Takes `{provider}` where the line names one. */ +/** What a refused connect says for the `reason` it carries next to its code, ahead of the code's line. */ +const CONNECT_REASONS: Record = { + no_model_list: { messageKey: 'assistant.connect.noModelList' }, +}; + +/** + * The line a failed connect shows. Takes `{provider}` where the line names one. + * An own server that answered without a model list is up, so it gets its own + * line about the address instead of "not responding" (#2808). + */ export function connectErrorKey(err: unknown): string { - return CONNECT_ERRORS[refusalCode(err) ?? '']?.messageKey ?? 'assistant.error.generic'; + const reason = (err as { response?: { data?: { reason?: unknown } } } | null)?.response?.data?.reason; + const byReason = typeof reason === 'string' ? CONNECT_REASONS[reason] : undefined; + return byReason?.messageKey ?? CONNECT_ERRORS[refusalCode(err) ?? '']?.messageKey ?? 'assistant.error.generic'; } /** How each connection state reads on its pill. */ diff --git a/server/src/nest/ai-connections/ai-connections.constants.ts b/server/src/nest/ai-connections/ai-connections.constants.ts index f40617fff..72b6f0cdb 100644 --- a/server/src/nest/ai-connections/ai-connections.constants.ts +++ b/server/src/nest/ai-connections/ai-connections.constants.ts @@ -91,7 +91,17 @@ const PROVIDER_MESSAGES: Partial> = { provider_unavailable: 'The provider is not responding', }; -/** A provider's failure as the refusal a REST route answers with. */ +/** + * A provider's failure as the refusal a REST route answers with. An own server + * that answered without a model list says so in `reason`, so the form can name + * the address instead of calling a server that is up unresponsive (#2808). + */ export function providerRefusal(err: AiProviderError): DomainError { + if (err.providerCode === 'no_model_list') { + return new DomainError(REFUSAL_STATUS[err.code], 'The server answered, but sent no model list', { + code: err.code, + details: { code: err.code, reason: 'no_model_list' }, + }); + } return aiRefusal(err.code, PROVIDER_MESSAGES[err.code] ?? 'The provider refused the request'); } diff --git a/server/src/nest/ai-connections/model-catalog.service.ts b/server/src/nest/ai-connections/model-catalog.service.ts index ab723cdb8..3913b482a 100644 --- a/server/src/nest/ai-connections/model-catalog.service.ts +++ b/server/src/nest/ai-connections/model-catalog.service.ts @@ -238,7 +238,15 @@ export class ModelCatalogService { const { models } = await this.llmLocal.listModels(baseUrl ?? undefined, apiKey ?? undefined); return models.map((m) => ({ id: m.name, label: m.name, supportsTools: true })); } catch (err) { - if (err instanceof DomainError) throw new AiProviderError('provider_unavailable', err.getStatus(), true); + // The server's own answer decides what the admin reads: a refused key, a + // server that answered without a model list, or one that is not there. + // All three read as "not responding" before, which sent people looking + // at a server that was up (#2808). + if (err instanceof DomainError) { + if (err.code === 'llm_key_refused') throw new AiProviderError('invalid_key', err.getStatus(), false); + const reason = err.code === 'llm_no_model_list' ? 'no_model_list' : undefined; + throw new AiProviderError('provider_unavailable', err.getStatus(), true, undefined, reason); + } throw err; } } diff --git a/server/src/nest/llm-parse/llm-local.service.ts b/server/src/nest/llm-parse/llm-local.service.ts index 370d10b6c..ee68bee66 100644 --- a/server/src/nest/llm-parse/llm-local.service.ts +++ b/server/src/nest/llm-parse/llm-local.service.ts @@ -26,6 +26,12 @@ const tagsResponseSchema = z.object({ /** The OpenAI-compatible list (`GET /v1/models`) that LM Studio, vLLM and llama.cpp serve. */ const openAiModelsSchema = z.object({ data: z.array(z.object({ id: z.string().optional() })) }); +/** One place a server may list its models, and how its answer reads. */ +interface ModelListSource { + url: string; + read: (body: unknown) => { name?: string; size?: number }[] | undefined; +} + /** The Bearer header the extraction sends, when a key is configured. */ function authHeader(apiKey: string | undefined): Record { return apiKey ? { authorization: `Bearer ${apiKey}` } : {}; @@ -43,11 +49,23 @@ function upstreamRefusal(status: number, apiKey: string | undefined, fallback: s apiKey ? `Local LLM server rejected the API key (${status})` : `Local LLM server requires an API key (${status}). Save the key for this address first.`, + { code: 'llm_key_refused' }, ); } return new DomainError(502, fallback); } +/** + * A URL without its trailing slashes. Scanned off instead of `/\/+$/`-replaced: + * that pattern re-walks the slash run from every start position of the + * admin-supplied URL. + */ +function trimTrailingSlashes(url: string): string { + let end = url.length; + while (end > 0 && url.charCodeAt(end - 1) === 47 /* '/' */) end--; + return url.slice(0, end); +} + /** * Admin helpers for managing a local OpenAI-compatible LLM server (Ollama). * Talks to Ollama's *management* API (`/api/tags`, `/api/pull`), which lives at @@ -72,11 +90,7 @@ export class LlmLocalService { if (url.protocol !== 'http:' && url.protocol !== 'https:') { throw new HttpException({ error: 'Base URL must be http(s)' }, 400); } - // Trailing slashes are scanned off instead of `/\/+$/`-replaced: that pattern - // re-walks the slash run from every start position of the admin-supplied URL. - let end = raw.length; - while (end > 0 && raw.charCodeAt(end - 1) === 47 /* '/' */) end--; - return raw.slice(0, end).replace(/\/v1$/, ''); + return trimTrailingSlashes(raw).replace(/\/v1$/, ''); } /** @@ -94,39 +108,69 @@ export class LlmLocalService { } /** - * List models already pulled on the local server. A server without Ollama's - * `/api/tags` (LM Studio, vLLM, llama.cpp) answers 404 there, so its - * OpenAI-compatible `/v1/models` is asked instead. + * List the models the server offers. Ollama's `/api/tags` is asked first, then + * the OpenAI-compatible list: at the address as entered (the one the chat + * calls `/chat/completions` on, `https://api.groq.com/openai/v1` say), then at + * `/v1/models` under the root for an address given without `/v1`. + * + * An answer only counts when it reads as a model list. LM Studio answers an + * unknown path with 200 and an error object, and a proxy may answer it with a + * login page, so stopping at the first answer that is not a 404 refused + * servers whose list was one request further (#2808). */ async listModels( baseUrl: string | undefined, apiKey?: string, ): Promise<{ models: { name: string; size: number }[] }> { const root = this.ollamaRoot(baseUrl); - let res = await this.getModelList(`${root}/api/tags`, root, apiKey); - let openAi = false; - if (res.status === 404) { - const fallback = await this.getModelList(`${root}/v1/models`, root, apiKey); - if (fallback.ok) { - discardBody(res); - res = fallback; - openAi = true; + const asEntered = trimTrailingSlashes((baseUrl ?? '').trim()) || root; + const lists: ModelListSource[] = [ + { url: `${root}/api/tags`, read: (body) => tagsResponseSchema.safeParse(body).data?.models }, + ...[...new Set([`${asEntered}/models`, `${root}/v1/models`])].map((url) => ({ + url, + read: (body: unknown) => openAiModelsSchema.safeParse(body).data?.data.map((m) => ({ name: m.id, size: 0 })), + })), + ]; + const seen = { firstStatus: 0, refusedStatus: 0 }; + const listed = await this.firstModelList(lists, 0, root, apiKey, seen); + if (listed) return { models: listed.map((m) => ({ name: m.name ?? '', size: m.size ?? 0 })).filter((m) => m.name) }; + if (seen.refusedStatus) throw upstreamRefusal(seen.refusedStatus, apiKey, ''); + throw new DomainError(502, `Local LLM server sent no model list (${seen.firstStatus})`, { + code: 'llm_no_model_list', + }); + } + + /** + * The first of `lists`, from `index` on, that answers with a readable list, + * asked one after the other. Only the first request tells whether the server + * is there at all; a later one failing is that path, not the server. + */ + private async firstModelList( + lists: ModelListSource[], + index: number, + root: string, + apiKey: string | undefined, + seen: { firstStatus: number; refusedStatus: number }, + ): Promise<{ name?: string; size?: number }[] | null> { + const list = lists[index]; + if (!list) return null; + let res: Response | null = null; + try { + res = await this.getModelList(list.url, root, apiKey); + } catch (err) { + if (index === 0) throw err; + } + if (res) { + seen.firstStatus ||= res.status; + if (res.status === 401 || res.status === 403) seen.refusedStatus ||= res.status; + if (res.ok) { + const listed = list.read(await readCappedJson(res, MAX_LIST_BYTES).catch(() => undefined)); + if (listed) return listed; } else { - // Neither list exists: report the first answer, as before. - discardBody(fallback); + discardBody(res); } } - if (!res.ok) { - discardBody(res); - throw upstreamRefusal(res.status, apiKey, `Local LLM server error (${res.status})`); - } - const body = await readCappedJson(res, MAX_LIST_BYTES); - const listed = openAi - ? openAiModelsSchema.safeParse(body).data?.data.map((m) => ({ name: m.id, size: 0 })) - : tagsResponseSchema.safeParse(body).data?.models; - if (!listed) throw new DomainError(502, 'Local LLM server sent an unreadable model list'); - const models = listed.map((m) => ({ name: m.name ?? '', size: m.size ?? 0 })).filter((m) => m.name); - return { models }; + return this.firstModelList(lists, index + 1, root, apiKey, seen); } private async getModelList(url: string, root: string, apiKey: string | undefined): Promise { diff --git a/server/src/nest/llm-parse/router/ollama-format.client.ts b/server/src/nest/llm-parse/router/ollama-format.client.ts index 9b2734fdd..6f2d4517c 100644 --- a/server/src/nest/llm-parse/router/ollama-format.client.ts +++ b/server/src/nest/llm-parse/router/ollama-format.client.ts @@ -1,5 +1,7 @@ /** - * Minimal Ollama native-API client used by the extraction router. + * Minimal Ollama native-API client used by the extraction router. A server that + * has no `/api/chat` gets the same extraction over OpenAI-compatible + * `/chat/completions` instead (see extractOpenAiCompatible below). * * Why not the OpenAI-compatible `/v1/chat/completions` path the rest of llm-parse uses? * Ollama's `/v1` endpoint does NOT faithfully honour OpenAI's `response_format:{json_schema,strict}` @@ -12,7 +14,9 @@ */ import { readEnv } from '../../../app-config'; import { safeFetchLlm } from '../../../utils/ssrfGuard'; +import { OpenAiCompatibleClient } from '../clients/openai-compatible.client'; import { parseLenientJson } from '../lenient-json'; +import type { LlmExtractionFile } from '../llm-provider.interface'; export interface EnforcedExtractInput { /** Ollama base URL — accepts the addon's `…/v1` form; the `/v1` suffix is stripped. */ @@ -40,6 +44,13 @@ export function toNativeBase(baseUrl: string): string { return baseUrl.slice(0, end).replace(/\/v1$/, ''); } +/** + * The answers that say the server has no `/api/chat` at all, unless the body is + * Ollama's own 404 for a model it has not pulled (OLLAMA_MISSING_MODEL). + */ +const NOT_OLLAMA_STATUSES = new Set([404, 405, 501]); +const OLLAMA_MISSING_MODEL = /model.*not found/i; + /** * Run one schema-constrained chat completion against Ollama's native `/api/chat`. * Returns the parsed JSON object (constrained to `schema`), or null if the request @@ -85,10 +96,61 @@ export async function extractEnforced(input: EnforcedExtractInput): Promise ''); + if (NOT_OLLAMA_STATUSES.has(res.status) && !OLLAMA_MISSING_MODEL.test(detail)) + return extractOpenAiCompatible(input); throw new Error(`Ollama /api/chat failed (${res.status}): ${detail.slice(0, 200)}`); } - const data = (await res.json()) as { message?: { content?: string } }; + const data = (await res.json().catch(() => null)) as { message?: { content?: string } } | null; + // LM Studio answers a path it does not serve with 200 and an error object, + // so an answer without Ollama's `message` is a server of another kind too. + if (!data || typeof data.message !== 'object') return extractOpenAiCompatible(input); const parsed = parseLenientJson(data.message?.content); return parsed && typeof parsed === 'object' ? (parsed as Record) : null; } + +/** + * The same extraction against an OpenAI-compatible server (Groq, vLLM, + * LM Studio, a LiteLLM proxy), which the "Own server" connection also names. + * It goes to `/chat/completions` at the address as entered, the endpoint the + * assistant chats on, through the client that already handles what such + * servers refuse (`json_schema`, `max_tokens`, `temperature`). The schema is + * asked for as a one-element list, the shape that client reads (#2806). + */ +async function extractOpenAiCompatible(input: EnforcedExtractInput): Promise | null> { + const [file, ...pageImages] = (input.images ?? []).map(imageFile); + const list = await new OpenAiCompatibleClient().extract({ + // The shape goes into the prompt as well: the client's later rungs send no + // schema (json_object, then nothing), and json_object wants the word JSON. + prompt: + `${input.system} Answer with JSON only, as {"result": [object]} where the object follows this ` + + `JSON Schema: ${JSON.stringify(input.schema)}`, + jsonSchema: { + type: 'object', + properties: { result: { type: 'array', items: input.schema } }, + required: ['result'], + }, + rootKey: 'result', + userText: input.user, + model: input.model, + baseUrl: input.baseUrl, + apiKey: input.apiKey, + file, + pageImages, + }); + const first = list[0]; + return first && typeof first === 'object' ? first : null; +} + +/** The first characters of a base64 image, per type. Anything else is sent as JPEG. */ +const IMAGE_PREFIXES: [string, string][] = [ + ['iVBOR', 'image/png'], + ['UklGR', 'image/webp'], + ['R0lGOD', 'image/gif'], +]; + +/** A base64 image as a file, its type read from its first bytes. */ +function imageFile(base64: string): LlmExtractionFile { + const mimeType = IMAGE_PREFIXES.find(([prefix]) => base64.startsWith(prefix))?.[1] ?? 'image/jpeg'; + return { mimeType, data: Buffer.from(base64, 'base64') }; +} diff --git a/server/tests/e2e/ai-own-server.e2e.test.ts b/server/tests/e2e/ai-own-server.e2e.test.ts new file mode 100644 index 000000000..dc5ea6854 --- /dev/null +++ b/server/tests/e2e/ai-own-server.e2e.test.ts @@ -0,0 +1,155 @@ +/** + * An "Own server" that is OpenAI-compatible but not Ollama, end to end: the + * whole app against a fake server on loopback that only answers under + * `/openai/v1`, the way Groq does, and 404s every Ollama path. + * + * Covered: connecting it as the instance connection (#2808), the refusal that + * says the server answered without a model list, a refused key, and a booking + * read through it by AI parsing, which used to call Ollama's `/api/chat` and + * fail with the server's 404 (#2806). + */ +import { buildApp } from '../../src/bootstrap'; +import { LlmParseService } from '../../src/nest/llm-parse/llm-parse.service'; +import { setAddonEnabled } from '../helpers/factories/settings'; +import { makeUser } from '../helpers/factories/users'; +import { resetRateLimits } from '../helpers/test-db'; +import { sessionCookie } from './harness'; +import { MikroORM } from '@mikro-orm/core'; +import type { INestApplication } from '@nestjs/common'; + +import { createServer, type IncomingMessage, type Server as HttpServer, type ServerResponse } from 'node:http'; +import type { AddressInfo } from 'node:net'; +import request from 'supertest'; +import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'; + +// ── The fake server ────────────────────────────────────────────────────────── + +/** How the fake answers: as Groq does, with 200 and a page for every path, or refusing every key. */ +const server = { mode: 'groq' as 'groq' | 'html' | 'refuse', seen: [] as string[], chats: [] as unknown[] }; + +async function readBody(req: IncomingMessage): Promise { + let text = ''; + for await (const chunk of req) text += String(chunk); + return text; +} + +function json(res: ServerResponse, status: number, body: unknown): void { + res.writeHead(status, { 'content-type': 'application/json' }); + res.end(JSON.stringify(body)); +} + +async function answer(req: IncomingMessage, res: ServerResponse): Promise { + server.seen.push(`${req.method} ${req.url}`); + const body = await readBody(req); + if (server.mode === 'refuse') return json(res, 401, { error: { message: 'Invalid API Key' } }); + if (server.mode === 'html') { + res.writeHead(200, { 'content-type': 'text/html' }); + res.end('Sign in'); + return; + } + if (req.method === 'GET' && req.url === '/openai/v1/models') { + return json(res, 200, { object: 'list', data: [{ id: 'openai/gpt-oss-120b', object: 'model' }] }); + } + if (req.method === 'POST' && req.url === '/openai/v1/chat/completions') { + server.chats.push(JSON.parse(body)); + const hotel = { + name: 'Hotel Sakura', + address: '1-2-3 Asakusa, Tokyo', + checkin_time: '2026-11-02T15:00:00', + checkout_time: '2026-11-05T11:00:00', + }; + const result = { result: [hotel] }; + return json(res, 200, { choices: [{ message: { content: JSON.stringify(result) }, finish_reason: 'stop' }] }); + } + json(res, 404, { + error: { + message: `Unknown request URL: ${req.method} ${req.url}.`, + type: 'invalid_request_error', + code: 'unknown_url', + }, + }); +} + +// ── The app ────────────────────────────────────────────────────────────────── + +let nestApp: INestApplication; +let orm: MikroORM; +let fake: HttpServer; +let adminId: number; + +function connect(apiKey = 'gsk_test'): request.Test { + const { port } = fake.address() as AddressInfo; + return request(nestApp.getHttpServer()) + .put('/api/admin/ai/connection') + .set('Cookie', sessionCookie(adminId)) + .send({ kind: 'custom', baseUrl: `http://127.0.0.1:${port}/openai/v1`, apiKey, model: 'openai/gpt-oss-120b' }); +} + +beforeAll(async () => { + fake = createServer((req, res) => { + answer(req, res).catch(() => res.destroy()); + }); + await new Promise((resolve) => fake.listen(0, '127.0.0.1', resolve)); + nestApp = await buildApp(); + orm = nestApp.get(MikroORM); + await setAddonEnabled(orm, 'ai_assistant', true); + adminId = (await makeUser(orm, { role: 'admin' })).user.id; +}); + +beforeEach(async () => { + await resetRateLimits(nestApp); + server.mode = 'groq'; + server.seen = []; + server.chats = []; +}); + +afterAll(async () => { + await nestApp.close(); + await new Promise((resolve) => fake.close(() => resolve())); +}); + +// ── Cases ──────────────────────────────────────────────────────────────────── + +describe('An OpenAI-compatible own server', () => { + it('AIOWN-E2E-001: connects, its models read from the list at the address as entered (#2808)', async () => { + const res = await connect(); + expect(res.status).toBe(200); + expect(server.seen.slice(0, 2)).toEqual(['GET /openai/api/tags', 'GET /openai/v1/models']); + }); + + it('AIOWN-E2E-002: a server that answers without a model list is told apart from one that is down', async () => { + server.mode = 'html'; + // Its own key, so the list the first case read is not taken from the catalog's cache. + const res = await connect('gsk_html'); + expect(res.status).toBe(502); + expect(res.body).toMatchObject({ code: 'provider_unavailable', reason: 'no_model_list' }); + }); + + it('AIOWN-E2E-003: a refused key reads as a refused key, not as a server that is down', async () => { + server.mode = 'refuse'; + const res = await connect('wrong'); + expect(res.status).toBe(422); + expect(res.body).toMatchObject({ code: 'invalid_key' }); + }); + + it('AIOWN-E2E-004: AI parsing reads a booking through /chat/completions when /api/chat is missing (#2806)', async () => { + expect((await connect()).status).toBe(200); + await setAddonEnabled(orm, 'llm_parsing', true); + server.seen = []; + const out = await nestApp + .get(LlmParseService) + .parse( + { + buffer: Buffer.from('Booking confirmation\nHotel Sakura, Tokyo\nCheck-in 2 Nov 2026, check-out 5 Nov 2026'), + originalName: 'booking.txt', + }, + adminId, + ); + expect(out.warnings.filter((w) => /failed/i.test(w))).toEqual([]); + expect(out.kiItems).toHaveLength(1); + expect(server.seen).toContain('POST /openai/api/chat'); + expect(server.seen).toContain('POST /openai/v1/chat/completions'); + const sent = server.chats[0] as { model: string; messages: { role: string }[] }; + expect(sent.model).toBe('openai/gpt-oss-120b'); + }); +}); diff --git a/server/tests/unit/nest/ai-connections/ai-connections.helpers.test.ts b/server/tests/unit/nest/ai-connections/ai-connections.helpers.test.ts index e2202ad33..0cb33cfdd 100644 --- a/server/tests/unit/nest/ai-connections/ai-connections.helpers.test.ts +++ b/server/tests/unit/nest/ai-connections/ai-connections.helpers.test.ts @@ -127,6 +127,16 @@ describe('constants', () => { }); }); + it('AIHLP-031b: an own server that answered without a model list says so in reason (#2808)', () => { + const err = providerRefusal(new AiProviderError('provider_unavailable', 404, true, undefined, 'no_model_list')); + expect(err.getStatus()).toBe(502); + expect(err.toBody()).toEqual({ + error: 'The server answered, but sent no model list', + code: 'provider_unavailable', + reason: 'no_model_list', + }); + }); + it('AIHLP-032: the host a conversation goes to', () => { expect(aiHostOf('anthropic', null)).toBe('api.anthropic.com'); expect(aiHostOf('chatgpt', null)).toBe('api.openai.com'); diff --git a/server/tests/unit/nest/ai-connections/model-catalog.service.test.ts b/server/tests/unit/nest/ai-connections/model-catalog.service.test.ts index d4a6b33fc..a7e3da012 100644 --- a/server/tests/unit/nest/ai-connections/model-catalog.service.test.ts +++ b/server/tests/unit/nest/ai-connections/model-catalog.service.test.ts @@ -201,6 +201,19 @@ describe('ModelCatalogService', () => { ).rejects.toMatchObject({ code: 'provider_unavailable', status: 502 }); }); + it('MCAT-007b: a custom server that refuses the key, or answers without a list, says so (#2808)', async () => { + const target = { kind: 'custom' as const, baseUrl: 'https://llm.example.org/v1', secret: 'k' }; + llmLocal.listModels.mockRejectedValueOnce(new DomainError(502, 'rejected', { code: 'llm_key_refused' })); + await expect(catalog().list(target)).rejects.toMatchObject({ code: 'invalid_key', retryable: false }); + llmLocal.listModels.mockRejectedValueOnce(new DomainError(502, 'no list', { code: 'llm_no_model_list' })); + await expect(catalog().list(target)).rejects.toMatchObject({ + code: 'provider_unavailable', + providerCode: 'no_model_list', + }); + llmLocal.listModels.mockRejectedValueOnce(new Error('boom')); + await expect(catalog().list(target)).rejects.toThrow('boom'); + }); + it('MCAT-008: the default model is a capable one, else the first listed', () => { const list = (...ids: string[]) => ids.map((id) => ({ id, label: id, supportsTools: true })); expect(pickDefaultModel('anthropic', list('claude-haiku', 'claude-sonnet-5', 'claude-opus'))).toBe( diff --git a/server/tests/unit/nest/llm-parse/llm-local.service.test.ts b/server/tests/unit/nest/llm-parse/llm-local.service.test.ts index 521b6bfa8..402ae2f81 100644 --- a/server/tests/unit/nest/llm-parse/llm-local.service.test.ts +++ b/server/tests/unit/nest/llm-parse/llm-local.service.test.ts @@ -96,11 +96,63 @@ describe('LlmLocalService.listModels', () => { expect(fetchFn.mock.calls[1][1].headers).toMatchObject({ authorization: 'Bearer k' }); }); - it('keeps the 404 when the OpenAI model list is missing too', async () => { - mockFetch(async () => ({ ok: false, status: 404, body: null })); + it('says no model list came, with the first status, when no list exists anywhere', async () => { + const fetchFn = mockFetch(async () => ({ ok: false, status: 404, body: null })); await expect(svc().listModels('http://nothing:1')).rejects.toMatchObject({ - response: { error: 'Local LLM server error (404)' }, + code: 'llm_no_model_list', + response: { error: 'Local LLM server sent no model list (404)' }, }); + expect(fetchFn.mock.calls.map((c: unknown[]) => c[0])).toEqual([ + 'http://nothing:1/api/tags', + 'http://nothing:1/models', + 'http://nothing:1/v1/models', + ]); + }); + + it('reads past an /api/tags that answers 200 without a model list, as LM Studio does (#2808)', async () => { + mockFetch(async (url?: string) => + url?.endsWith('/api/tags') + ? { ok: true, status: 200, json: async () => ({ error: 'Unexpected endpoint or method. (GET /api/tags)' }) } + : { ok: true, status: 200, json: async () => ({ data: [{ id: 'qwen3-8b' }] }) }, + ); + expect((await svc().listModels('http://lmstudio:1234/v1')).models).toEqual([{ name: 'qwen3-8b', size: 0 }]); + }); + + it('asks the address as entered when it does not end in /v1 (#2808)', async () => { + const fetchFn = mockFetch(async (url?: string) => + url === 'https://owui.example.org/api/models' + ? { ok: true, status: 200, json: async () => ({ data: [{ id: 'llama3.3' }] }) } + : { ok: false, status: 404, body: null }, + ); + expect((await svc().listModels('https://owui.example.org/api/', 'k')).models).toEqual([ + { name: 'llama3.3', size: 0 }, + ]); + expect(fetchFn.mock.calls.map((c: unknown[]) => c[0])).toEqual([ + 'https://owui.example.org/api/api/tags', + 'https://owui.example.org/api/models', + ]); + }); + + it('reports a refused key even when the refusal came from a later list', async () => { + mockFetch(async (url?: string) => + url?.endsWith('/api/tags') ? { ok: false, status: 404, body: null } : { ok: false, status: 401, body: null }, + ); + await expect(svc().listModels('https://api.groq.com/openai/v1', 'bad')).rejects.toMatchObject({ + code: 'llm_key_refused', + response: { error: 'Local LLM server rejected the API key (401)' }, + }); + }); + + it('skips a later list that cannot be reached, and a body that is not JSON', async () => { + safeFetchLlmMock + .mockImplementationOnce(async () => ({ + ok: true, + status: 200, + json: async () => Promise.reject(new Error('html')), + })) + .mockImplementationOnce(() => Promise.reject(new Error('ECONNRESET'))) + .mockImplementationOnce(async () => ({ ok: true, status: 200, json: async () => ({ data: [{ id: 'm' }] }) })); + expect((await svc().listModels('http://vllm:8000')).models).toEqual([{ name: 'm', size: 0 }]); }); it('502s when the server is unreachable', async () => { diff --git a/server/tests/unit/nest/llm-parse/ollama-format.client.test.ts b/server/tests/unit/nest/llm-parse/ollama-format.client.test.ts index 8d88048fa..6cf87d813 100644 --- a/server/tests/unit/nest/llm-parse/ollama-format.client.test.ts +++ b/server/tests/unit/nest/llm-parse/ollama-format.client.test.ts @@ -95,4 +95,78 @@ describe('extractEnforced', () => { mockFetch(() => jsonResponse({ error: 'model not found' }, false, 404)); await expect(extractEnforced(INPUT)).rejects.toThrow(/Ollama \/api\/chat failed \(404\)/); }); + + it('throws for a server error without trying another path', async () => { + const fetchFn = mockFetch(() => jsonResponse({ error: 'boom' }, false, 500)); + await expect(extractEnforced(INPUT)).rejects.toThrow(/failed \(500\)/); + expect(fetchFn).toHaveBeenCalledTimes(1); + }); +}); + +describe('extractEnforced on an OpenAI-compatible server (#2806)', () => { + const GROQ = { ...INPUT, baseUrl: 'https://api.groq.com/openai/v1', model: 'openai/gpt-oss-120b', apiKey: 'gsk' }; + const chatAnswer = (content: string) => jsonResponse({ choices: [{ message: { content } }] }); + const unknownUrl = (url: string) => + jsonResponse( + { error: { message: `Unknown request URL: POST ${new URL(url).pathname}.`, code: 'unknown_url' } }, + false, + 404, + ); + + it('sends the extraction to /chat/completions at the address as entered when /api/chat is missing', async () => { + const fetchFn = mockFetch((url) => + url.endsWith('/api/chat') ? unknownUrl(url) : chatAnswer('{"result":[{"name":"Hotel"}]}'), + ); + expect(await extractEnforced(GROQ)).toEqual({ name: 'Hotel' }); + expect(fetchFn.mock.calls.map((c) => c[0])).toEqual([ + 'https://api.groq.com/openai/api/chat', + 'https://api.groq.com/openai/v1/chat/completions', + ]); + const init = fetchFn.mock.calls[1][1] as RequestInit; + expect((init.headers as Record).authorization).toBe('Bearer gsk'); + const body = JSON.parse(init.body as string); + expect(body.model).toBe('openai/gpt-oss-120b'); + expect(body.response_format.json_schema.schema).toEqual({ + type: 'object', + properties: { result: { type: 'array', items: { type: 'object' } } }, + required: ['result'], + }); + expect(body.messages[0].content).toContain('{"result": [object]}'); + expect(body.messages[1].content[0].text).toBe('doc'); + }); + + it('falls back on a 405 or 501 too, and on a 200 that is not an Ollama answer (LM Studio)', async () => { + for (const first of [ + jsonResponse({}, false, 405), + jsonResponse({}, false, 501), + jsonResponse({ error: 'Unexpected endpoint' }), + ]) { + mockFetch((url) => (url.endsWith('/api/chat') ? first : chatAnswer('{"result":[{"a":1}]}'))); + expect(await extractEnforced(GROQ)).toEqual({ a: 1 }); + } + }); + + it('answers null when the server returns no object', async () => { + mockFetch((url) => (url.endsWith('/api/chat') ? unknownUrl(url) : chatAnswer('{"result":[]}'))); + expect(await extractEnforced(GROQ)).toBeNull(); + }); + + it('passes the images on as image parts with their type', async () => { + const fetchFn = mockFetch((url) => (url.endsWith('/api/chat') ? unknownUrl(url) : chatAnswer('{"result":[{}]}'))); + await extractEnforced({ ...GROQ, images: ['iVBORw0K', '/9j/4AAQ', 'UklGRiQA', 'R0lGODlh'] }); + const parts = JSON.parse((fetchFn.mock.calls[1][1] as RequestInit).body as string).messages[1].content; + expect(parts.slice(1).map((p: { image_url: { url: string } }) => p.image_url.url.split(';')[0])).toEqual([ + 'data:image/png', + 'data:image/jpeg', + 'data:image/webp', + 'data:image/gif', + ]); + }); + + it('reports the OpenAI-compatible failure when that path fails too', async () => { + mockFetch((url) => + url.endsWith('/api/chat') ? unknownUrl(url) : jsonResponse({ error: 'bad model' }, false, 404), + ); + await expect(extractEnforced(GROQ)).rejects.toThrow(/LLM request failed \(404\)/); + }); }); diff --git a/shared/src/i18n/ar/assistant.ts b/shared/src/i18n/ar/assistant.ts index 791b538ad..d7de4b89c 100644 --- a/shared/src/i18n/ar/assistant.ts +++ b/shared/src/i18n/ar/assistant.ts @@ -39,6 +39,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'فتح المساعد', 'assistant.connect.badKey': 'هذا المفتاح لا يعمل.', 'assistant.connect.unknownModel': 'هذا النموذج غير متاح هنا.', + 'assistant.connect.noModelList': + 'استجاب الخادم، لكنه لم يرسل قائمة بالنماذج. تحقّق من العنوان، فهو ينتهي عادةً بـ /v1.', 'assistant.connect.getKey': 'الحصول على مفتاح', 'assistant.connect.hintAnthropic': 'تتضمن باقتا Claude Max وTeam رصيدًا لـ API.', 'assistant.connect.hintOpenai': 'أنشئ مفتاحًا في لوحة تحكم OpenAI.', diff --git a/shared/src/i18n/az/assistant.ts b/shared/src/i18n/az/assistant.ts index 315445662..a05d2f8ad 100644 --- a/shared/src/i18n/az/assistant.ts +++ b/shared/src/i18n/az/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Köməkçini aç', 'assistant.connect.badKey': 'Bu açar işləmir.', 'assistant.connect.unknownModel': 'Bu model burada təklif olunmur.', + 'assistant.connect.noModelList': + 'Server cavab verdi, amma model siyahısı göndərmədi. Ünvanı yoxlayın, adətən /v1 ilə bitir.', 'assistant.connect.getKey': 'Açar əldə et', 'assistant.connect.hintAnthropic': 'Claude Max və Team planlarına API kreditləri daxildir.', 'assistant.connect.hintOpenai': 'OpenAI panelinizdə açar yaradın.', diff --git a/shared/src/i18n/br/assistant.ts b/shared/src/i18n/br/assistant.ts index 062310d89..c763fc59c 100644 --- a/shared/src/i18n/br/assistant.ts +++ b/shared/src/i18n/br/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Abrir assistente', 'assistant.connect.badKey': 'Esta chave não funciona.', 'assistant.connect.unknownModel': 'Este modelo não está disponível aqui.', + 'assistant.connect.noModelList': + 'O servidor respondeu, mas não enviou uma lista de modelos. Confira o endereço, ele costuma terminar em /v1.', 'assistant.connect.getKey': 'Obter uma chave', 'assistant.connect.hintAnthropic': 'Claude Max e Team incluem créditos de API.', 'assistant.connect.hintOpenai': 'Crie uma chave no seu painel da OpenAI.', diff --git a/shared/src/i18n/ca/assistant.ts b/shared/src/i18n/ca/assistant.ts index 214a713e8..96d7447f0 100644 --- a/shared/src/i18n/ca/assistant.ts +++ b/shared/src/i18n/ca/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Obre l’assistent', 'assistant.connect.badKey': 'Aquesta clau no funciona.', 'assistant.connect.unknownModel': 'Aquest model no s’ofereix aquí.', + 'assistant.connect.noModelList': + 'El servidor ha respost, però no ha enviat cap llista de models. Revisa l’adreça, normalment acaba en /v1.', 'assistant.connect.getKey': 'Obtén una clau', 'assistant.connect.hintAnthropic': 'Claude Max i Team inclouen crèdits d’API.', 'assistant.connect.hintOpenai': 'Crea una clau al teu tauler d’OpenAI.', diff --git a/shared/src/i18n/cs/assistant.ts b/shared/src/i18n/cs/assistant.ts index b26e58230..3d3cdb268 100644 --- a/shared/src/i18n/cs/assistant.ts +++ b/shared/src/i18n/cs/assistant.ts @@ -40,6 +40,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Otevřít asistenta', 'assistant.connect.badKey': 'Tento klíč nefunguje.', 'assistant.connect.unknownModel': 'Tento model tu není k dispozici.', + 'assistant.connect.noModelList': + 'Server odpověděl, ale neposlal seznam modelů. Zkontrolujte adresu, obvykle končí na /v1.', 'assistant.connect.getKey': 'Získat klíč', 'assistant.connect.hintAnthropic': 'Claude Max a Team zahrnují kredity API.', 'assistant.connect.hintOpenai': 'Vytvoř klíč na svém panelu OpenAI.', diff --git a/shared/src/i18n/de/assistant.ts b/shared/src/i18n/de/assistant.ts index afda30d39..3aedabdbb 100644 --- a/shared/src/i18n/de/assistant.ts +++ b/shared/src/i18n/de/assistant.ts @@ -42,6 +42,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Assistent öffnen', 'assistant.connect.badKey': 'Dieser Schlüssel funktioniert nicht.', 'assistant.connect.unknownModel': 'Dieses Modell wird hier nicht angeboten.', + 'assistant.connect.noModelList': + 'Der Server antwortet, schickt aber keine Modellliste. Prüfe die Adresse, meist endet sie auf /v1.', 'assistant.connect.getKey': 'Schlüssel holen', 'assistant.connect.hintAnthropic': 'Claude Max und Team enthalten API-Guthaben.', 'assistant.connect.hintOpenai': 'Leg einen Schlüssel in deinem OpenAI-Dashboard an.', diff --git a/shared/src/i18n/en/assistant.ts b/shared/src/i18n/en/assistant.ts index df2459299..93025da13 100644 --- a/shared/src/i18n/en/assistant.ts +++ b/shared/src/i18n/en/assistant.ts @@ -40,6 +40,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Open assistant', 'assistant.connect.badKey': 'This key doesn’t work.', 'assistant.connect.unknownModel': 'This model isn’t offered here.', + 'assistant.connect.noModelList': + 'The server answered, but sent no list of models. Check the address, it usually ends in /v1.', 'assistant.connect.getKey': 'Get a key', 'assistant.connect.hintAnthropic': 'Claude Max and Team include API credits.', 'assistant.connect.hintOpenai': 'Create a key in your OpenAI dashboard.', diff --git a/shared/src/i18n/es/assistant.ts b/shared/src/i18n/es/assistant.ts index addc4051e..6042bbf0e 100644 --- a/shared/src/i18n/es/assistant.ts +++ b/shared/src/i18n/es/assistant.ts @@ -40,6 +40,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Abrir asistente', 'assistant.connect.badKey': 'Esta clave no funciona.', 'assistant.connect.unknownModel': 'Este modelo no está disponible aquí.', + 'assistant.connect.noModelList': + 'El servidor respondió, pero no envió una lista de modelos. Revisa la dirección, suele terminar en /v1.', 'assistant.connect.getKey': 'Obtener una clave', 'assistant.connect.hintAnthropic': 'Claude Max y Team incluyen créditos de API.', 'assistant.connect.hintOpenai': 'Crea una clave en tu panel de OpenAI.', diff --git a/shared/src/i18n/et/assistant.ts b/shared/src/i18n/et/assistant.ts index 76e1d9125..2d9865931 100644 --- a/shared/src/i18n/et/assistant.ts +++ b/shared/src/i18n/et/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Ava assistent', 'assistant.connect.badKey': 'See võti ei tööta.', 'assistant.connect.unknownModel': 'Seda mudelit siin ei pakuta.', + 'assistant.connect.noModelList': + 'Server vastas, kuid ei saatnud mudelite loendit. Kontrolli aadressi, tavaliselt lõpeb see /v1-ga.', 'assistant.connect.getKey': 'Hangi võti', 'assistant.connect.hintAnthropic': 'Claude Max ja Team sisaldavad API-krediiti.', 'assistant.connect.hintOpenai': 'Loo võti oma OpenAI juhtpaneelil.', diff --git a/shared/src/i18n/fr/assistant.ts b/shared/src/i18n/fr/assistant.ts index a62feff66..138c989d1 100644 --- a/shared/src/i18n/fr/assistant.ts +++ b/shared/src/i18n/fr/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Ouvrir l’assistant', 'assistant.connect.badKey': 'Cette clé ne fonctionne pas.', 'assistant.connect.unknownModel': 'Ce modèle n’est pas proposé ici.', + 'assistant.connect.noModelList': + 'Le serveur a répondu, mais sans liste de modèles. Vérifiez l’adresse, elle se termine généralement par /v1.', 'assistant.connect.getKey': 'Obtenir une clé', 'assistant.connect.hintAnthropic': 'Claude Max et Team incluent des crédits API.', 'assistant.connect.hintOpenai': 'Créez une clé dans votre tableau de bord OpenAI.', diff --git a/shared/src/i18n/gr/assistant.ts b/shared/src/i18n/gr/assistant.ts index 256640b2a..79a09a958 100644 --- a/shared/src/i18n/gr/assistant.ts +++ b/shared/src/i18n/gr/assistant.ts @@ -42,6 +42,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Άνοιγμα βοηθού', 'assistant.connect.badKey': 'Αυτό το κλειδί δεν λειτουργεί.', 'assistant.connect.unknownModel': 'Αυτό το μοντέλο δεν προσφέρεται εδώ.', + 'assistant.connect.noModelList': + 'Ο διακομιστής απάντησε, αλλά δεν έστειλε λίστα μοντέλων. Ελέγξτε τη διεύθυνση, συνήθως τελειώνει σε /v1.', 'assistant.connect.getKey': 'Λήψη κλειδιού', 'assistant.connect.hintAnthropic': 'Τα Claude Max και Team περιλαμβάνουν μονάδες API.', 'assistant.connect.hintOpenai': 'Δημιουργήστε ένα κλειδί στον πίνακα ελέγχου του OpenAI.', diff --git a/shared/src/i18n/hu/assistant.ts b/shared/src/i18n/hu/assistant.ts index b56f6dfe3..618f87d41 100644 --- a/shared/src/i18n/hu/assistant.ts +++ b/shared/src/i18n/hu/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Asszisztens megnyitása', 'assistant.connect.badKey': 'Ez a kulcs nem működik.', 'assistant.connect.unknownModel': 'Ez a modell itt nem érhető el.', + 'assistant.connect.noModelList': + 'A szerver válaszolt, de nem küldött modellistát. Ellenőrizd a címet, általában /v1-re végződik.', 'assistant.connect.getKey': 'Kulcs igénylése', 'assistant.connect.hintAnthropic': 'A Claude Max és Team csomag API-kreditet is tartalmaz.', 'assistant.connect.hintOpenai': 'Hozz létre egy kulcsot az OpenAI irányítópultján.', diff --git a/shared/src/i18n/id/assistant.ts b/shared/src/i18n/id/assistant.ts index 89b168626..bc012b635 100644 --- a/shared/src/i18n/id/assistant.ts +++ b/shared/src/i18n/id/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Buka asisten', 'assistant.connect.badKey': 'Kunci ini tidak berfungsi.', 'assistant.connect.unknownModel': 'Model ini tidak tersedia di sini.', + 'assistant.connect.noModelList': + 'Server menjawab, tetapi tidak mengirim daftar model. Periksa alamatnya, biasanya diakhiri dengan /v1.', 'assistant.connect.getKey': 'Dapatkan kunci', 'assistant.connect.hintAnthropic': 'Claude Max dan Team sudah termasuk kredit API.', 'assistant.connect.hintOpenai': 'Buat kunci di dasbor OpenAI kamu.', diff --git a/shared/src/i18n/it/assistant.ts b/shared/src/i18n/it/assistant.ts index 1253d5725..c851cac98 100644 --- a/shared/src/i18n/it/assistant.ts +++ b/shared/src/i18n/it/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Apri l’assistente', 'assistant.connect.badKey': 'Questa chiave non funziona.', 'assistant.connect.unknownModel': 'Questo modello non è disponibile qui.', + 'assistant.connect.noModelList': + 'Il server ha risposto, ma non ha inviato un elenco di modelli. Controlla l’indirizzo, di solito termina con /v1.', 'assistant.connect.getKey': 'Ottieni una chiave', 'assistant.connect.hintAnthropic': 'Claude Max e Team includono crediti API.', 'assistant.connect.hintOpenai': 'Crea una chiave nella dashboard di OpenAI.', diff --git a/shared/src/i18n/ja/assistant.ts b/shared/src/i18n/ja/assistant.ts index 449a7dbf3..5101c1bc2 100644 --- a/shared/src/i18n/ja/assistant.ts +++ b/shared/src/i18n/ja/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'アシスタントを開く', 'assistant.connect.badKey': 'このキーは使えません。', 'assistant.connect.unknownModel': 'このモデルはここでは提供されていません。', + 'assistant.connect.noModelList': + 'サーバーは応答しましたが、モデル一覧が返りませんでした。アドレスを確認してください。通常は /v1 で終わります。', 'assistant.connect.getKey': 'キーを取得', 'assistant.connect.hintAnthropic': 'Claude Max と Team には API クレジットが含まれています。', 'assistant.connect.hintOpenai': 'OpenAI のダッシュボードでキーを作成してください。', diff --git a/shared/src/i18n/ko/assistant.ts b/shared/src/i18n/ko/assistant.ts index f68b08f81..90e3fd33f 100644 --- a/shared/src/i18n/ko/assistant.ts +++ b/shared/src/i18n/ko/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': '어시스턴트 열기', 'assistant.connect.badKey': '이 키는 작동하지 않습니다.', 'assistant.connect.unknownModel': '이 모델은 여기에서 제공되지 않습니다.', + 'assistant.connect.noModelList': + '서버가 응답했지만 모델 목록을 보내지 않았습니다. 주소를 확인하세요. 보통 /v1로 끝납니다.', 'assistant.connect.getKey': '키 받기', 'assistant.connect.hintAnthropic': 'Claude Max와 Team에는 API 크레딧이 포함되어 있습니다.', 'assistant.connect.hintOpenai': 'OpenAI 대시보드에서 키를 만드세요.', diff --git a/shared/src/i18n/nl/assistant.ts b/shared/src/i18n/nl/assistant.ts index 91a1755c8..718190ebc 100644 --- a/shared/src/i18n/nl/assistant.ts +++ b/shared/src/i18n/nl/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Assistent openen', 'assistant.connect.badKey': 'Deze sleutel werkt niet.', 'assistant.connect.unknownModel': 'Dit model wordt hier niet aangeboden.', + 'assistant.connect.noModelList': + 'De server antwoordde, maar stuurde geen lijst met modellen. Controleer het adres, dat eindigt meestal op /v1.', 'assistant.connect.getKey': 'Sleutel aanvragen', 'assistant.connect.hintAnthropic': 'Claude Max en Team bevatten API-tegoed.', 'assistant.connect.hintOpenai': 'Maak een sleutel aan in je OpenAI-dashboard.', diff --git a/shared/src/i18n/pl/assistant.ts b/shared/src/i18n/pl/assistant.ts index 588cf053d..6cef78538 100644 --- a/shared/src/i18n/pl/assistant.ts +++ b/shared/src/i18n/pl/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Otwórz asystenta', 'assistant.connect.badKey': 'Ten klucz nie działa.', 'assistant.connect.unknownModel': 'Ten model nie jest tu dostępny.', + 'assistant.connect.noModelList': + 'Serwer odpowiedział, ale nie przesłał listy modeli. Sprawdź adres, zwykle kończy się na /v1.', 'assistant.connect.getKey': 'Uzyskaj klucz', 'assistant.connect.hintAnthropic': 'Claude Max i Team zawierają środki na API.', 'assistant.connect.hintOpenai': 'Utwórz klucz w panelu OpenAI.', diff --git a/shared/src/i18n/ru/assistant.ts b/shared/src/i18n/ru/assistant.ts index aea9b58ce..e8c1a5869 100644 --- a/shared/src/i18n/ru/assistant.ts +++ b/shared/src/i18n/ru/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Открыть ассистента', 'assistant.connect.badKey': 'Этот ключ не работает.', 'assistant.connect.unknownModel': 'Эта модель здесь недоступна.', + 'assistant.connect.noModelList': + 'Сервер ответил, но не прислал список моделей. Проверьте адрес, обычно он заканчивается на /v1.', 'assistant.connect.getKey': 'Получить ключ', 'assistant.connect.hintAnthropic': 'В Claude Max и Team входят кредиты API.', 'assistant.connect.hintOpenai': 'Создайте ключ в панели управления OpenAI.', diff --git a/shared/src/i18n/sk/assistant.ts b/shared/src/i18n/sk/assistant.ts index 988298739..03a5d7ba5 100644 --- a/shared/src/i18n/sk/assistant.ts +++ b/shared/src/i18n/sk/assistant.ts @@ -40,6 +40,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Otvoriť asistenta', 'assistant.connect.badKey': 'Tento kľúč nefunguje.', 'assistant.connect.unknownModel': 'Tento model tu nie je k dispozícii.', + 'assistant.connect.noModelList': + 'Server odpovedal, ale neposlal zoznam modelov. Skontrolujte adresu, zvyčajne končí na /v1.', 'assistant.connect.getKey': 'Získať kľúč', 'assistant.connect.hintAnthropic': 'Claude Max a Team obsahujú kredity pre API.', 'assistant.connect.hintOpenai': 'Vytvor kľúč vo svojom prehľade OpenAI.', diff --git a/shared/src/i18n/sv/assistant.ts b/shared/src/i18n/sv/assistant.ts index 0393a4aaa..55fe59b8f 100644 --- a/shared/src/i18n/sv/assistant.ts +++ b/shared/src/i18n/sv/assistant.ts @@ -42,6 +42,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Öppna assistenten', 'assistant.connect.badKey': 'Den här nyckeln fungerar inte.', 'assistant.connect.unknownModel': 'Den här modellen erbjuds inte här.', + 'assistant.connect.noModelList': + 'Servern svarade men skickade ingen lista med modeller. Kontrollera adressen, den slutar oftast på /v1.', 'assistant.connect.getKey': 'Skaffa en nyckel', 'assistant.connect.hintAnthropic': 'Claude Max och Team inkluderar API-krediter.', 'assistant.connect.hintOpenai': 'Skapa en nyckel i din OpenAI-översikt.', diff --git a/shared/src/i18n/th/assistant.ts b/shared/src/i18n/th/assistant.ts index 985d8fa9d..484b2c6f8 100644 --- a/shared/src/i18n/th/assistant.ts +++ b/shared/src/i18n/th/assistant.ts @@ -40,6 +40,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'เปิดผู้ช่วย', 'assistant.connect.badKey': 'คีย์นี้ใช้งานไม่ได้', 'assistant.connect.unknownModel': 'ไม่มีโมเดลนี้ให้ใช้ที่นี่', + 'assistant.connect.noModelList': + 'เซิร์ฟเวอร์ตอบกลับแล้ว แต่ไม่ได้ส่งรายการโมเดลมา ตรวจสอบที่อยู่ ซึ่งมักลงท้ายด้วย /v1', 'assistant.connect.getKey': 'รับคีย์', 'assistant.connect.hintAnthropic': 'Claude Max และ Team มีเครดิต API รวมอยู่ด้วย', 'assistant.connect.hintOpenai': 'สร้างคีย์ในแดชบอร์ด OpenAI ของคุณ', diff --git a/shared/src/i18n/tr/assistant.ts b/shared/src/i18n/tr/assistant.ts index b7bfd0e94..76b0ad8c0 100644 --- a/shared/src/i18n/tr/assistant.ts +++ b/shared/src/i18n/tr/assistant.ts @@ -40,6 +40,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Asistanı aç', 'assistant.connect.badKey': 'Bu anahtar çalışmıyor.', 'assistant.connect.unknownModel': 'Bu model burada sunulmuyor.', + 'assistant.connect.noModelList': + 'Sunucu yanıt verdi ama model listesi göndermedi. Adresi kontrol edin, genellikle /v1 ile biter.', 'assistant.connect.getKey': 'Anahtar al', 'assistant.connect.hintAnthropic': 'Claude Max ve Team, API kredisi içerir.', 'assistant.connect.hintOpenai': 'OpenAI panelinde bir anahtar oluştur.', diff --git a/shared/src/i18n/uk/assistant.ts b/shared/src/i18n/uk/assistant.ts index ab7f495da..fb04854ba 100644 --- a/shared/src/i18n/uk/assistant.ts +++ b/shared/src/i18n/uk/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Відкрити асистента', 'assistant.connect.badKey': 'Цей ключ не працює.', 'assistant.connect.unknownModel': 'Ця модель тут недоступна.', + 'assistant.connect.noModelList': + 'Сервер відповів, але не надіслав список моделей. Перевірте адресу, зазвичай вона закінчується на /v1.', 'assistant.connect.getKey': 'Отримати ключ', 'assistant.connect.hintAnthropic': 'Claude Max і Team містять кредити API.', 'assistant.connect.hintOpenai': 'Створіть ключ у панелі керування OpenAI.', diff --git a/shared/src/i18n/vi/assistant.ts b/shared/src/i18n/vi/assistant.ts index d6c08978b..baf8b0b36 100644 --- a/shared/src/i18n/vi/assistant.ts +++ b/shared/src/i18n/vi/assistant.ts @@ -41,6 +41,8 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': 'Mở trợ lý', 'assistant.connect.badKey': 'Khóa này không hoạt động.', 'assistant.connect.unknownModel': 'Mô hình này không có ở đây.', + 'assistant.connect.noModelList': + 'Máy chủ đã phản hồi nhưng không gửi danh sách mô hình. Hãy kiểm tra địa chỉ, thường kết thúc bằng /v1.', 'assistant.connect.getKey': 'Lấy khóa', 'assistant.connect.hintAnthropic': 'Claude Max và Team có kèm tín dụng API.', 'assistant.connect.hintOpenai': 'Tạo khóa trong bảng điều khiển OpenAI của bạn.', diff --git a/shared/src/i18n/zh-TW/assistant.ts b/shared/src/i18n/zh-TW/assistant.ts index 97bf6c4ef..ebde4c656 100644 --- a/shared/src/i18n/zh-TW/assistant.ts +++ b/shared/src/i18n/zh-TW/assistant.ts @@ -39,6 +39,7 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': '開啟助理', 'assistant.connect.badKey': '這組金鑰無效。', 'assistant.connect.unknownModel': '這裡不提供此模型。', + 'assistant.connect.noModelList': '伺服器已回應,但沒有傳回模型清單。請檢查位址,通常以 /v1 結尾。', 'assistant.connect.getKey': '取得金鑰', 'assistant.connect.hintAnthropic': 'Claude Max 和 Team 包含 API 額度。', 'assistant.connect.hintOpenai': '在你的 OpenAI 主控台建立金鑰。', diff --git a/shared/src/i18n/zh/assistant.ts b/shared/src/i18n/zh/assistant.ts index 5f2f7a809..f1b0d1318 100644 --- a/shared/src/i18n/zh/assistant.ts +++ b/shared/src/i18n/zh/assistant.ts @@ -39,6 +39,7 @@ const assistant: TranslationStrings = { 'assistant.connect.openAssistant': '打开助手', 'assistant.connect.badKey': '此密钥无效。', 'assistant.connect.unknownModel': '此处不提供该模型。', + 'assistant.connect.noModelList': '服务器已响应,但没有返回模型列表。请检查地址,通常以 /v1 结尾。', 'assistant.connect.getKey': '获取密钥', 'assistant.connect.hintAnthropic': 'Claude Max 和 Team 包含 API 额度。', 'assistant.connect.hintOpenai': '在你的 OpenAI 控制台中创建密钥。', diff --git a/wiki/AI-Booking-Import.md b/wiki/AI-Booking-Import.md index 38769e0cb..4411f9835 100644 --- a/wiki/AI-Booking-Import.md +++ b/wiki/AI-Booking-Import.md @@ -44,7 +44,7 @@ The shared connection of the AI assistant supports these providers: | **Gemini** | Google's OpenAI-compatible endpoint | Needs an API key. | | **OpenRouter** | OpenRouter's API | **Connect OpenRouter** signs you in, so there is no key to copy. | | **Sign in with ChatGPT** | ChatGPT | Uses a ChatGPT plan, no key. Chat only, not used for parsing. | -| **Own server** | Your own hardware | Any OpenAI-compatible server, for example Ollama, at a **Server address** you enter. The API key is optional. | +| **Own server** | Your own hardware, or any OpenAI-compatible service | Ollama, LM Studio, vLLM, llama.cpp, a LiteLLM proxy or a hosted endpoint such as Groq, at a **Server address** you enter: the one that `/chat/completions` follows, usually ending in `/v1` (`http://localhost:11434/v1`, `https://api.groq.com/openai/v1`). Ollama is read through its own API, every other server through `/chat/completions`. The API key is optional. | To connect, pick **Sign in with ChatGPT**, **Paste an API key** or **Own server**. When you paste a key, TREK shows *Detected: {provider}*; if it cannot tell, it asks *Which provider is this key from?*. **Connect OpenRouter** is offered as its own button.