ui : add backend types and constants

Assisted-by: pi:llama.cpp/DeepSeek-V4.1-Flash
This commit is contained in:
Aleksander Grygier
2026-09-16 19:22:47 +02:00
parent 21aecafc8c
commit 1d2cc0daae
4 changed files with 44 additions and 0 deletions
@@ -0,0 +1,10 @@
import type { BackendProtocol } from '$lib/types';
/** Id of the built-in backend that points at the server serving this UI. */
export const LOCAL_BACKEND_ID = 'local';
/** Protocols a configured backend can speak, in display order. */
export const BACKEND_PROTOCOLS: readonly BackendProtocol[] = ['llama.cpp', 'openai', 'anthropic'];
/** Prefix for generated ids of user-added backends. */
export const BACKEND_ID_PREFIX = 'backend';
+1
View File
@@ -4,6 +4,7 @@
export * from './agentic.constants';
export * from './api-endpoints.constants';
export * from './app.constants';
export * from './backend.constants';
export * from './chat-tabs.constants';
export * from './database.constants';
export * from './reasoning-effort.constants';
+30
View File
@@ -0,0 +1,30 @@
/**
* Backend types.
*
* A backend is one API endpoint the UI can talk to. The built-in `local`
* backend is the llama-server serving the UI. External backends are
* user-configured endpoints that speak an OpenAI- or Anthropic-compatible
* protocol.
*/
/** Request/response shape a backend speaks. */
export type BackendProtocol = 'llama.cpp' | 'openai' | 'anthropic';
/** One configured API endpoint. */
export interface Backend {
/** Bearer token / API key used for this backend. */
apiKey?: string;
/**
* API root the endpoint paths are appended to, e.g. https://api.example.com.
* Empty for the local backend, which resolves against the UI origin instead.
*/
baseUrl: string;
/** Disabled backends stay configured but are not queried. */
enabled: boolean;
/** Extra headers merged into every request to this backend. */
headers?: Record<string, string>;
/** Stable identity. The local backend id is reserved. */
id: string;
name: string;
protocol: BackendProtocol;
}
+3
View File
@@ -35,6 +35,9 @@ export type {
ApiStreamSession
} from './api';
// Backend types
export type { Backend, BackendProtocol } from './backend';
// HuggingFace types
export type {
HfCatalogBuild,