index.ts 3.1 KB

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