index.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 showSettings = writable(false);
  32. export const showChangelog = writable(false);
  33. type Model = OpenAIModel | OllamaModel;
  34. type OpenAIModel = {
  35. id: string;
  36. name: string;
  37. external: boolean;
  38. source?: string;
  39. };
  40. type OllamaModel = {
  41. id: string;
  42. name: string;
  43. // Ollama specific fields
  44. details: OllamaModelDetails;
  45. size: number;
  46. description: string;
  47. model: string;
  48. modified_at: string;
  49. digest: string;
  50. };
  51. type OllamaModelDetails = {
  52. parent_model: string;
  53. format: string;
  54. family: string;
  55. families: string[] | null;
  56. parameter_size: string;
  57. quantization_level: string;
  58. };
  59. type Settings = {
  60. models?: string[];
  61. conversationMode?: boolean;
  62. speechAutoSend?: boolean;
  63. responseAutoPlayback?: boolean;
  64. audio?: AudioSettings;
  65. showUsername?: boolean;
  66. saveChatHistory?: boolean;
  67. notificationEnabled?: boolean;
  68. title?: TitleSettings;
  69. splitLargeDeltas?: boolean;
  70. system?: string;
  71. requestFormat?: string;
  72. keepAlive?: string;
  73. seed?: number;
  74. temperature?: string;
  75. repeat_penalty?: string;
  76. top_k?: string;
  77. top_p?: string;
  78. num_ctx?: string;
  79. options?: ModelOptions;
  80. };
  81. type ModelOptions = {
  82. stop?: boolean;
  83. };
  84. type AudioSettings = {
  85. STTEngine?: string;
  86. TTSEngine?: string;
  87. speaker?: string;
  88. };
  89. type TitleSettings = {
  90. auto?: boolean;
  91. model?: string;
  92. modelExternal?: string;
  93. prompt?: string;
  94. };
  95. type Prompt = {
  96. command: string;
  97. user_id: string;
  98. title: string;
  99. content: string;
  100. timestamp: number;
  101. };
  102. type Config = {
  103. status?: boolean;
  104. name?: string;
  105. version?: string;
  106. default_locale?: string;
  107. images?: boolean;
  108. default_models?: string[];
  109. default_prompt_suggestions?: PromptSuggestion[];
  110. trusted_header_auth?: boolean;
  111. };
  112. type PromptSuggestion = {
  113. content: string;
  114. title: [string, string];
  115. };
  116. type SessionUser = {
  117. id: string;
  118. email: string;
  119. name: string;
  120. role: string;
  121. profile_image_url: string;
  122. };