index.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import { APP_NAME } from '$lib/constants';
  2. import { type Writable, writable } from 'svelte/store';
  3. import type { GlobalModelConfig, ModelConfig } from '$lib/apis';
  4. import type { Banner } from '$lib/types';
  5. // Backend
  6. export const WEBUI_NAME = writable(APP_NAME);
  7. export const config: Writable<Config | undefined> = writable(undefined);
  8. export const user: Writable<SessionUser | undefined> = writable(undefined);
  9. // Frontend
  10. export const MODEL_DOWNLOAD_POOL = writable({});
  11. export const mobile = writable(false);
  12. export const theme = writable('system');
  13. export const chatId = writable('');
  14. export const chats = writable([]);
  15. export const tags = writable([]);
  16. export const models: Writable<Model[]> = writable([]);
  17. export const modelfiles = writable([]);
  18. export const prompts: Writable<Prompt[]> = writable([]);
  19. export const documents = writable([
  20. {
  21. collection_name: 'collection_name',
  22. filename: 'filename',
  23. name: 'name',
  24. title: 'title'
  25. },
  26. {
  27. collection_name: 'collection_name1',
  28. filename: 'filename1',
  29. name: 'name1',
  30. title: 'title1'
  31. }
  32. ]);
  33. export const banners: Writable<Banner[]> = writable([]);
  34. export const settings: Writable<Settings> = writable({});
  35. export const showSidebar = writable(false);
  36. export const showSettings = writable(false);
  37. export const showArchivedChats = writable(false);
  38. export const showChangelog = writable(false);
  39. export type Model = OpenAIModel | OllamaModel;
  40. type BaseModel = {
  41. id: string;
  42. name: string;
  43. info?: ModelConfig;
  44. };
  45. export interface OpenAIModel extends BaseModel {
  46. external: boolean;
  47. source?: string;
  48. }
  49. export interface OllamaModel extends BaseModel {
  50. details: OllamaModelDetails;
  51. size: number;
  52. description: string;
  53. model: string;
  54. modified_at: string;
  55. digest: string;
  56. }
  57. type OllamaModelDetails = {
  58. parent_model: string;
  59. format: string;
  60. family: string;
  61. families: string[] | null;
  62. parameter_size: string;
  63. quantization_level: string;
  64. };
  65. type Settings = {
  66. models?: string[];
  67. conversationMode?: boolean;
  68. speechAutoSend?: boolean;
  69. responseAutoPlayback?: boolean;
  70. audio?: AudioSettings;
  71. showUsername?: boolean;
  72. saveChatHistory?: boolean;
  73. notificationEnabled?: boolean;
  74. title?: TitleSettings;
  75. splitLargeDeltas?: boolean;
  76. chatDirection: 'LTR' | 'RTL';
  77. system?: string;
  78. requestFormat?: string;
  79. keepAlive?: string;
  80. seed?: number;
  81. temperature?: string;
  82. repeat_penalty?: string;
  83. top_k?: string;
  84. top_p?: string;
  85. num_ctx?: string;
  86. options?: ModelOptions;
  87. };
  88. type ModelOptions = {
  89. stop?: boolean;
  90. };
  91. type AudioSettings = {
  92. STTEngine?: string;
  93. TTSEngine?: string;
  94. speaker?: string;
  95. model?: string;
  96. };
  97. type TitleSettings = {
  98. auto?: boolean;
  99. model?: string;
  100. modelExternal?: string;
  101. prompt?: string;
  102. };
  103. type Prompt = {
  104. command: string;
  105. user_id: string;
  106. title: string;
  107. content: string;
  108. timestamp: number;
  109. };
  110. type Config = {
  111. status: boolean;
  112. name: string;
  113. version: string;
  114. default_locale: string;
  115. default_models: string[];
  116. default_prompt_suggestions: PromptSuggestion[];
  117. features: {
  118. auth: boolean;
  119. auth_trusted_header: boolean;
  120. enable_signup: boolean;
  121. enable_websearch?: boolean;
  122. enable_image_generation: boolean;
  123. enable_admin_export: boolean;
  124. enable_community_sharing: boolean;
  125. };
  126. };
  127. type PromptSuggestion = {
  128. content: string;
  129. title: [string, string];
  130. };
  131. type SessionUser = {
  132. id: string;
  133. email: string;
  134. name: string;
  135. role: string;
  136. profile_image_url: string;
  137. };