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';
|
2024-12-31 10:26:30 +00:00
|
|
|
import type { ModelConfig } from '$lib/apis';
|
2024-05-26 19:18:43 +00:00
|
|
|
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
|
|
|
|
2024-12-30 10:20:09 +00:00
|
|
|
import emojiShortCodes from '$lib/emoji-shortcodes.json';
|
|
|
|
|
|
2023-11-20 01:47:07 +00:00
|
|
|
// Backend
|
2024-02-24 01:12:19 +00:00
|
|
|
export const WEBUI_NAME = writable(APP_NAME);
|
2024-04-22 17:15:07 +00:00
|
|
|
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
|
2024-03-25 06:03:26 +00:00
|
|
|
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-12-27 07:29:33 +00:00
|
|
|
export const activeUserIds: Writable<null | string[]> = 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
|
|
|
|
2024-03-25 06:03:26 +00:00
|
|
|
export const theme = writable('system');
|
2024-09-26 01:21:37 +00:00
|
|
|
|
2024-12-31 10:26:30 +00:00
|
|
|
export const shortCodesToEmojis = writable(
|
|
|
|
|
Object.entries(emojiShortCodes).reduce((acc, [key, value]) => {
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
|
acc[value] = key;
|
|
|
|
|
} else {
|
|
|
|
|
for (const v of value) {
|
|
|
|
|
acc[v] = key;
|
|
|
|
|
}
|
2024-12-30 10:20:09 +00:00
|
|
|
}
|
|
|
|
|
|
2024-12-31 10:26:30 +00:00
|
|
|
return acc;
|
|
|
|
|
}, {})
|
|
|
|
|
);
|
2024-12-30 10:20:09 +00:00
|
|
|
|
2023-11-20 01:47:07 +00:00
|
|
|
export const chatId = writable('');
|
2024-09-26 01:21:37 +00:00
|
|
|
export const chatTitle = writable('');
|
2024-01-03 04:41:37 +00:00
|
|
|
|
2024-12-22 11:10:10 +00:00
|
|
|
export const channels = writable([]);
|
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([]);
|
2024-06-20 08:44:52 +00:00
|
|
|
|
2024-11-12 23:31:11 +00:00
|
|
|
export const prompts: Writable<null | Prompt[]> = writable(null);
|
|
|
|
|
export const knowledge: Writable<null | Document[]> = writable(null);
|
|
|
|
|
export const tools = writable(null);
|
|
|
|
|
export const functions = writable(null);
|
|
|
|
|
|
2024-05-26 19:18:43 +00:00
|
|
|
export const banners: Writable<Banner[]> = writable([]);
|
|
|
|
|
|
2024-04-22 17:15:07 +00:00
|
|
|
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-09-17 20:05:19 +00:00
|
|
|
|
|
|
|
|
export const showControls = writable(false);
|
|
|
|
|
export const showOverview = writable(false);
|
2024-10-06 06:58:02 +00:00
|
|
|
export const showArtifacts = writable(false);
|
2024-06-07 05:30:19 +00:00
|
|
|
export const showCallOverlay = writable(false);
|
2024-04-21 10:41:18 +00:00
|
|
|
|
2024-08-15 14:54:16 +00:00
|
|
|
export const temporaryChatEnabled = writable(false);
|
2024-08-04 15:31:41 +00:00
|
|
|
export const scrollPaginationEnabled = writable(false);
|
2024-08-04 15:11:41 +00:00
|
|
|
export const currentChatPage = writable(1);
|
2024-04-21 10:41:18 +00:00
|
|
|
|
2025-01-04 10:05:42 +00:00
|
|
|
|
|
|
|
|
export const playingNotificationSound = writable(false);
|
|
|
|
|
|
2024-05-09 12:25:30 +00:00
|
|
|
export type Model = OpenAIModel | OllamaModel;
|
2024-04-21 10:41:18 +00:00
|
|
|
|
2024-05-09 12:25:30 +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-10-22 10:16:48 +00:00
|
|
|
owned_by: 'ollama' | 'openai' | 'arena';
|
2024-05-09 12:25:30 +00:00
|
|
|
};
|
2024-04-21 10:41:18 +00:00
|
|
|
|
2024-05-09 15:49:54 +00:00
|
|
|
export interface OpenAIModel extends BaseModel {
|
2024-08-20 00:44:09 +00:00
|
|
|
owned_by: 'openai';
|
2024-05-09 12:25:30 +00:00
|
|
|
external: boolean;
|
|
|
|
|
source?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-09 15:49:54 +00:00
|
|
|
export interface OllamaModel extends BaseModel {
|
2024-08-20 00:44:09 +00:00
|
|
|
owned_by: 'ollama';
|
2024-04-21 10:41:18 +00:00
|
|
|
details: OllamaModelDetails;
|
|
|
|
|
size: number;
|
|
|
|
|
description: string;
|
|
|
|
|
model: string;
|
|
|
|
|
modified_at: string;
|
|
|
|
|
digest: string;
|
2024-08-20 00:44:09 +00:00
|
|
|
ollama?: {
|
|
|
|
|
name?: string;
|
|
|
|
|
model?: string;
|
|
|
|
|
modified_at: string;
|
|
|
|
|
size?: number;
|
|
|
|
|
digest?: string;
|
|
|
|
|
details?: {
|
|
|
|
|
parent_model?: string;
|
|
|
|
|
format?: string;
|
|
|
|
|
family?: string;
|
|
|
|
|
families?: string[];
|
|
|
|
|
parameter_size?: string;
|
|
|
|
|
quantization_level?: string;
|
|
|
|
|
};
|
|
|
|
|
urls?: number[];
|
|
|
|
|
};
|
2024-05-09 12:25:30 +00:00
|
|
|
}
|
2024-04-21 10:41:18 +00:00
|
|
|
|
|
|
|
|
type OllamaModelDetails = {
|
2024-04-22 17:15:07 +00:00
|
|
|
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;
|
|
|
|
|
notificationEnabled?: boolean;
|
|
|
|
|
title?: TitleSettings;
|
2024-04-30 19:43:43 +00:00
|
|
|
splitLargeDeltas?: boolean;
|
2024-05-16 20:14:54 +00:00
|
|
|
chatDirection: 'LTR' | 'RTL';
|
2024-04-22 17:15:07 +00:00
|
|
|
|
|
|
|
|
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;
|
2024-04-22 17:15:07 +00:00
|
|
|
options?: ModelOptions;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type ModelOptions = {
|
|
|
|
|
stop?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type AudioSettings = {
|
|
|
|
|
STTEngine?: string;
|
|
|
|
|
TTSEngine?: string;
|
|
|
|
|
speaker?: string;
|
2024-05-07 00:28:34 +00:00
|
|
|
model?: string;
|
2024-06-03 18:09:55 +00:00
|
|
|
nonLocalVoices?: boolean;
|
2024-04-22 17:15:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-22 17:15:07 +00:00
|
|
|
type Config = {
|
2024-05-26 16:05:26 +00:00
|
|
|
status: boolean;
|
|
|
|
|
name: string;
|
|
|
|
|
version: string;
|
|
|
|
|
default_locale: string;
|
2024-07-10 06:43:28 +00:00
|
|
|
default_models: string;
|
2024-05-26 16:05:26 +00:00
|
|
|
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-11-19 20:17:23 +00:00
|
|
|
enable_api_key: boolean;
|
2024-05-27 19:48:08 +00:00
|
|
|
enable_signup: boolean;
|
2024-07-25 01:44:40 +00:00
|
|
|
enable_login_form: boolean;
|
2024-05-27 19:48:08 +00:00
|
|
|
enable_web_search?: boolean;
|
2024-12-19 02:04:56 +00:00
|
|
|
enable_google_drive_integration: boolean;
|
2024-05-26 16:10:25 +00:00
|
|
|
enable_image_generation: boolean;
|
|
|
|
|
enable_admin_export: boolean;
|
2024-08-04 14:16:14 +00:00
|
|
|
enable_admin_chat_access: boolean;
|
2024-05-26 16:10:25 +00:00
|
|
|
enable_community_sharing: boolean;
|
2024-05-26 16:05:26 +00:00
|
|
|
};
|
2024-05-26 07:37:09 +00:00
|
|
|
oauth: {
|
|
|
|
|
providers: {
|
|
|
|
|
[key: string]: string;
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-05-09 12:25:30 +00:00
|
|
|
};
|
|
|
|
|
|
2024-04-22 17:15:07 +00:00
|
|
|
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
|
|
|
};
|