open-webui/src/lib/stores/index.ts

173 lines
3.8 KiB
TypeScript
Raw Normal View History

2024-02-24 01:12:19 +00:00
import { APP_NAME } from '$lib/constants';
2024-04-21 10:41:18 +00:00
import { type Writable, writable } from 'svelte/store';
import type { GlobalModelConfig, ModelConfig } from '$lib/apis';
import type { Banner } from '$lib/types';
2024-06-04 06:39:52 +00:00
import type { Socket } from 'socket.io-client';
2023-11-19 00:47:12 +00:00
2023-11-20 01:47:07 +00:00
// Backend
2024-02-24 01:12:19 +00:00
export const WEBUI_NAME = writable(APP_NAME);
export const config: Writable<Config | undefined> = writable(undefined);
export const user: Writable<SessionUser | undefined> = writable(undefined);
2023-11-20 01:47:07 +00:00
// Frontend
export const MODEL_DOWNLOAD_POOL = writable({});
2024-01-03 04:41:37 +00:00
2024-05-14 22:26:53 +00:00
export const mobile = writable(false);
2024-06-04 06:39:52 +00:00
export const socket: Writable<null | Socket> = writable(null);
2024-06-04 08:10:31 +00:00
export const activeUserCount: Writable<null | number> = writable(null);
2024-06-04 18:13:43 +00:00
export const USAGE_POOL: Writable<null | string[]> = writable(null);
2024-06-04 06:39:52 +00:00
export const theme = writable('system');
2023-11-20 01:47:07 +00:00
export const chatId = writable('');
2024-01-03 04:41:37 +00:00
2023-11-20 01:47:07 +00:00
export const chats = writable([]);
2024-07-02 06:08:01 +00:00
export const pinnedChats = writable([]);
2024-01-18 10:55:25 +00:00
export const tags = writable([]);
2024-01-08 07:43:32 +00:00
2024-06-11 03:39:55 +00:00
export const models: Writable<Model[]> = writable([]);
export const prompts: Writable<Prompt[]> = writable([]);
2024-06-11 03:39:55 +00:00
export const documents: Writable<Document[]> = writable([]);
2024-06-20 08:44:52 +00:00
2024-06-11 03:39:55 +00:00
export const tools = writable([]);
2024-06-20 08:44:52 +00:00
export const functions = writable([]);
2024-01-02 00:05:05 +00:00
export const banners: Writable<Banner[]> = writable([]);
export const settings: Writable<Settings> = writable({});
2024-04-30 23:34:29 +00:00
export const showSidebar = writable(false);
2023-11-20 01:47:07 +00:00
export const showSettings = writable(false);
2024-05-15 08:22:15 +00:00
export const showArchivedChats = writable(false);
2024-02-23 08:47:54 +00:00
export const showChangelog = writable(false);
2024-06-07 05:30:19 +00:00
export const showCallOverlay = writable(false);
2024-04-21 10:41:18 +00:00
export type Model = OpenAIModel | OllamaModel;
2024-04-21 10:41:18 +00:00
type BaseModel = {
2024-04-21 10:41:18 +00:00
id: string;
name: string;
2024-05-25 01:26:36 +00:00
info?: ModelConfig;
};
2024-04-21 10:41:18 +00:00
export interface OpenAIModel extends BaseModel {
external: boolean;
source?: string;
}
export interface OllamaModel extends BaseModel {
2024-04-21 10:41:18 +00:00
details: OllamaModelDetails;
size: number;
description: string;
model: string;
modified_at: string;
digest: string;
}
2024-04-21 10:41:18 +00:00
type OllamaModelDetails = {
parent_model: string;
format: string;
family: string;
families: string[] | null;
parameter_size: string;
quantization_level: string;
};
type Settings = {
models?: string[];
conversationMode?: boolean;
speechAutoSend?: boolean;
responseAutoPlayback?: boolean;
audio?: AudioSettings;
showUsername?: boolean;
saveChatHistory?: boolean;
notificationEnabled?: boolean;
title?: TitleSettings;
splitLargeDeltas?: boolean;
chatDirection: 'LTR' | 'RTL';
system?: string;
requestFormat?: string;
keepAlive?: string;
seed?: number;
temperature?: string;
repeat_penalty?: string;
top_k?: string;
top_p?: string;
num_ctx?: string;
2024-06-14 05:31:26 +00:00
num_batch?: string;
num_keep?: string;
options?: ModelOptions;
};
type ModelOptions = {
stop?: boolean;
};
type AudioSettings = {
STTEngine?: string;
TTSEngine?: string;
speaker?: string;
2024-05-07 00:28:34 +00:00
model?: string;
nonLocalVoices?: boolean;
};
type TitleSettings = {
auto?: boolean;
model?: string;
modelExternal?: string;
prompt?: string;
};
type Prompt = {
command: string;
user_id: string;
title: string;
content: string;
timestamp: number;
};
2024-06-11 03:39:55 +00:00
type Document = {
collection_name: string;
filename: string;
name: string;
title: string;
};
type Config = {
status: boolean;
name: string;
version: string;
default_locale: string;
default_models: string;
default_prompt_suggestions: PromptSuggestion[];
2024-05-26 20:02:40 +00:00
features: {
2024-05-26 16:10:25 +00:00
auth: boolean;
auth_trusted_header: boolean;
2024-05-27 19:48:08 +00:00
enable_signup: boolean;
enable_login_form: boolean;
2024-05-27 19:48:08 +00:00
enable_web_search?: boolean;
2024-05-26 16:10:25 +00:00
enable_image_generation: boolean;
enable_admin_export: boolean;
enable_community_sharing: boolean;
};
oauth: {
providers: {
[key: string]: string;
};
};
};
type PromptSuggestion = {
content: string;
title: [string, string];
};
type SessionUser = {
id: string;
email: string;
name: string;
role: string;
profile_image_url: string;
2024-04-21 10:41:18 +00:00
};