index.ts 2.8 KB

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