JoFrost commited on
Commit
5528541
1 Parent(s): e66a6c5

update to current version

Browse files
.env CHANGED
@@ -32,6 +32,8 @@ MODELS=`[
32
  {
33
  "name": "Xenova/LaMini-Flan-T5-783M",
34
  "is_local": true,
 
 
35
  "userMessageToken": "<|prompter|>",
36
  "assistantMessageToken": "<|assistant|>",
37
  "messageEndToken": "</s>",
@@ -49,12 +51,40 @@ MODELS=`[
49
  }
50
  ],
51
  "parameters": {
52
- "temperature": 0.9,
53
  "top_p": 0.95,
54
  "repetition_penalty": 1.2,
55
  "top_k": 50,
56
  "truncate": 1000,
57
- "max_new_tokens": 1024
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
  }
60
  ]`
@@ -79,7 +109,7 @@ PARQUET_EXPORT_SECRET=
79
  RATE_LIMIT= # requests per minute
80
  MESSAGES_BEFORE_LOGIN=# how many messages a user can send in a conversation before having to login. set to 0 to force login right away
81
 
82
- PUBLIC_APP_NAME=BlindChat # name used as title throughout the app
83
  PUBLIC_APP_ASSETS=chatui # used to find logos & favicons in static/$PUBLIC_APP_ASSETS
84
  PUBLIC_APP_COLOR=blue # can be any of tailwind colors: https://tailwindcss.com/docs/customizing-colors#default-color-palette
85
  PUBLIC_APP_DATA_SHARING=#set to 1 to enable options & text regarding data sharing
 
32
  {
33
  "name": "Xenova/LaMini-Flan-T5-783M",
34
  "is_local": true,
35
+ "is_code": false,
36
+ "type": "text2text-generation",
37
  "userMessageToken": "<|prompter|>",
38
  "assistantMessageToken": "<|assistant|>",
39
  "messageEndToken": "</s>",
 
51
  }
52
  ],
53
  "parameters": {
54
+ "temperature": 0.8,
55
  "top_p": 0.95,
56
  "repetition_penalty": 1.2,
57
  "top_k": 50,
58
  "truncate": 1000,
59
+ "max_new_tokens": 256
60
+ }
61
+ },
62
+ {
63
+ "name": "Xenova/codegen-350M-mono",
64
+ "is_local": true,
65
+ "is_code": true,
66
+ "type": "text-generation",
67
+ "userMessageToken": "<|prompter|>",
68
+ "assistantMessageToken": "<|assistant|>",
69
+ "messageEndToken": "</s>",
70
+ "preprompt": "",
71
+ "promptExamples": [
72
+ {
73
+ "title": "Calculates the nth Fibonacci number",
74
+ "prompt": "def fib(n):\n '''Calculates the nth Fibonacci number'''"
75
+ },
76
+ {
77
+ "title": "Reimplement your own math.sqrt function",
78
+ "prompt": "def sqrt(n):\n '''Reimplement your own math.sqrt function'''"
79
+ }
80
+ ],
81
+ "parameters": {
82
+ "temperature": 0.5,
83
+ "top_p": 0.95,
84
+ "repetition_penalty": 1.2,
85
+ "top_k": 50,
86
+ "truncate": 1000,
87
+ "max_new_tokens": 45
88
  }
89
  }
90
  ]`
 
109
  RATE_LIMIT= # requests per minute
110
  MESSAGES_BEFORE_LOGIN=# how many messages a user can send in a conversation before having to login. set to 0 to force login right away
111
 
112
+ PUBLIC_APP_NAME=ChatUI # name used as title throughout the app
113
  PUBLIC_APP_ASSETS=chatui # used to find logos & favicons in static/$PUBLIC_APP_ASSETS
114
  PUBLIC_APP_COLOR=blue # can be any of tailwind colors: https://tailwindcss.com/docs/customizing-colors#default-color-palette
115
  PUBLIC_APP_DATA_SHARING=#set to 1 to enable options & text regarding data sharing
.svelte-kit/ambient.d.ts CHANGED
@@ -51,107 +51,91 @@ declare module '$env/static/private' {
51
  export const PARQUET_EXPORT_SECRET: string;
52
  export const RATE_LIMIT: string;
53
  export const MESSAGES_BEFORE_LOGIN: string;
54
- export const LESSOPEN: string;
55
- export const LANGUAGE: string;
56
- export const USER: string;
57
- export const npm_config_user_agent: string;
58
- export const XDG_SEAT: string;
59
- export const XDG_SESSION_TYPE: string;
 
 
 
 
 
 
 
 
 
60
  export const GIT_ASKPASS: string;
61
- export const npm_node_execpath: string;
62
- export const SHLVL: string;
63
- export const npm_config_noproxy: string;
64
  export const HOME: string;
65
- export const CHROME_DESKTOP: string;
66
- export const OLDPWD: string;
67
- export const TERM_PROGRAM_VERSION: string;
68
- export const DESKTOP_SESSION: string;
69
- export const NVM_BIN: string;
70
- export const npm_package_json: string;
71
- export const NVM_INC: string;
72
- export const HOMEBREW_PREFIX: string;
73
- export const GTK_MODULES: string;
74
- export const XDG_SEAT_PATH: string;
75
- export const VSCODE_GIT_ASKPASS_MAIN: string;
76
- export const LC_MONETARY: string;
77
- export const VSCODE_GIT_ASKPASS_NODE: string;
78
- export const npm_config_userconfig: string;
79
- export const npm_config_local_prefix: string;
80
- export const CINNAMON_VERSION: string;
81
- export const DBUS_SESSION_BUS_ADDRESS: string;
82
  export const npm_config_engine_strict: string;
83
- export const COLORTERM: string;
84
- export const COLOR: string;
85
- export const NVM_DIR: string;
 
86
  export const npm_config_metrics_registry: string;
87
- export const QT_QPA_PLATFORMTHEME: string;
88
- export const INFOPATH: string;
89
- export const LOGNAME: string;
90
- export const _: string;
91
- export const npm_config_prefix: string;
92
- export const XDG_SESSION_CLASS: string;
93
- export const TERM: string;
94
- export const GTK_OVERLAY_SCROLLING: string;
95
- export const XDG_SESSION_ID: string;
96
- export const npm_config_cache: string;
97
- export const GNOME_DESKTOP_SESSION_ID: string;
98
  export const npm_config_node_gyp: string;
99
- export const PATH: string;
100
- export const SESSION_MANAGER: string;
101
- export const GDM_LANG: string;
102
- export const HOMEBREW_CELLAR: string;
103
- export const GTK3_MODULES: string;
104
- export const NODE: string;
105
- export const npm_package_name: string;
106
- export const XDG_SESSION_PATH: string;
107
- export const LC_ADDRESS: string;
108
- export const GNOME_TERMINAL_SCREEN: string;
109
- export const XDG_RUNTIME_DIR: string;
110
- export const GDK_BACKEND: string;
111
- export const DISPLAY: string;
112
- export const LANG: string;
113
- export const XDG_CURRENT_DESKTOP: string;
114
- export const LC_TELEPHONE: string;
115
- export const XDG_SESSION_DESKTOP: string;
116
- export const XAUTHORITY: string;
117
- export const LS_COLORS: string;
118
- export const VSCODE_GIT_IPC_HANDLE: string;
119
- export const GNOME_TERMINAL_SERVICE: string;
120
- export const TERM_PROGRAM: string;
121
  export const npm_lifecycle_script: string;
122
- export const SSH_AUTH_SOCK: string;
123
- export const XDG_GREETER_DATA_DIR: string;
124
- export const ORIGINAL_XDG_CURRENT_DESKTOP: string;
125
- export const SHELL: string;
126
- export const LC_NAME: string;
127
  export const npm_package_version: string;
128
- export const npm_lifecycle_event: string;
129
- export const QT_ACCESSIBILITY: string;
130
- export const NO_AT_BRIDGE: string;
131
- export const GDMSESSION: string;
132
- export const LESSCLOSE: string;
133
- export const LC_MEASUREMENT: string;
134
- export const GPG_AGENT_INFO: string;
135
- export const LC_IDENTIFICATION: string;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  export const VSCODE_GIT_ASKPASS_EXTRA_ARGS: string;
137
- export const XDG_VTNR: string;
138
- export const npm_config_globalconfig: string;
139
- export const npm_config_init_module: string;
140
- export const PWD: string;
141
- export const npm_execpath: string;
142
- export const XDG_CONFIG_DIRS: string;
143
- export const NVM_CD_FLAGS: string;
144
- export const XDG_DATA_DIRS: string;
145
- export const npm_config_global_prefix: string;
146
- export const HOMEBREW_REPOSITORY: string;
147
- export const LC_NUMERIC: string;
148
- export const npm_command: string;
149
- export const LC_PAPER: string;
150
- export const MANPATH: string;
151
- export const VTE_VERSION: string;
152
- export const INIT_CWD: string;
153
- export const EDITOR: string;
154
- export const NODE_ENV: string;
155
  }
156
 
157
  /**
@@ -216,107 +200,91 @@ declare module '$env/dynamic/private' {
216
  PARQUET_EXPORT_SECRET: string;
217
  RATE_LIMIT: string;
218
  MESSAGES_BEFORE_LOGIN: string;
219
- LESSOPEN: string;
220
- LANGUAGE: string;
221
- USER: string;
222
- npm_config_user_agent: string;
223
- XDG_SEAT: string;
224
- XDG_SESSION_TYPE: string;
 
 
 
 
 
 
 
 
 
225
  GIT_ASKPASS: string;
226
- npm_node_execpath: string;
227
- SHLVL: string;
228
- npm_config_noproxy: string;
229
  HOME: string;
230
- CHROME_DESKTOP: string;
231
- OLDPWD: string;
232
- TERM_PROGRAM_VERSION: string;
233
- DESKTOP_SESSION: string;
234
- NVM_BIN: string;
235
- npm_package_json: string;
236
- NVM_INC: string;
237
- HOMEBREW_PREFIX: string;
238
- GTK_MODULES: string;
239
- XDG_SEAT_PATH: string;
240
- VSCODE_GIT_ASKPASS_MAIN: string;
241
- LC_MONETARY: string;
242
- VSCODE_GIT_ASKPASS_NODE: string;
243
- npm_config_userconfig: string;
244
- npm_config_local_prefix: string;
245
- CINNAMON_VERSION: string;
246
- DBUS_SESSION_BUS_ADDRESS: string;
247
  npm_config_engine_strict: string;
248
- COLORTERM: string;
249
- COLOR: string;
250
- NVM_DIR: string;
 
251
  npm_config_metrics_registry: string;
252
- QT_QPA_PLATFORMTHEME: string;
253
- INFOPATH: string;
254
- LOGNAME: string;
255
- _: string;
256
- npm_config_prefix: string;
257
- XDG_SESSION_CLASS: string;
258
- TERM: string;
259
- GTK_OVERLAY_SCROLLING: string;
260
- XDG_SESSION_ID: string;
261
- npm_config_cache: string;
262
- GNOME_DESKTOP_SESSION_ID: string;
263
  npm_config_node_gyp: string;
264
- PATH: string;
265
- SESSION_MANAGER: string;
266
- GDM_LANG: string;
267
- HOMEBREW_CELLAR: string;
268
- GTK3_MODULES: string;
269
- NODE: string;
270
- npm_package_name: string;
271
- XDG_SESSION_PATH: string;
272
- LC_ADDRESS: string;
273
- GNOME_TERMINAL_SCREEN: string;
274
- XDG_RUNTIME_DIR: string;
275
- GDK_BACKEND: string;
276
- DISPLAY: string;
277
- LANG: string;
278
- XDG_CURRENT_DESKTOP: string;
279
- LC_TELEPHONE: string;
280
- XDG_SESSION_DESKTOP: string;
281
- XAUTHORITY: string;
282
- LS_COLORS: string;
283
- VSCODE_GIT_IPC_HANDLE: string;
284
- GNOME_TERMINAL_SERVICE: string;
285
- TERM_PROGRAM: string;
286
  npm_lifecycle_script: string;
287
- SSH_AUTH_SOCK: string;
288
- XDG_GREETER_DATA_DIR: string;
289
- ORIGINAL_XDG_CURRENT_DESKTOP: string;
290
- SHELL: string;
291
- LC_NAME: string;
292
  npm_package_version: string;
293
- npm_lifecycle_event: string;
294
- QT_ACCESSIBILITY: string;
295
- NO_AT_BRIDGE: string;
296
- GDMSESSION: string;
297
- LESSCLOSE: string;
298
- LC_MEASUREMENT: string;
299
- GPG_AGENT_INFO: string;
300
- LC_IDENTIFICATION: string;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  VSCODE_GIT_ASKPASS_EXTRA_ARGS: string;
302
- XDG_VTNR: string;
303
- npm_config_globalconfig: string;
304
- npm_config_init_module: string;
305
- PWD: string;
306
- npm_execpath: string;
307
- XDG_CONFIG_DIRS: string;
308
- NVM_CD_FLAGS: string;
309
- XDG_DATA_DIRS: string;
310
- npm_config_global_prefix: string;
311
- HOMEBREW_REPOSITORY: string;
312
- LC_NUMERIC: string;
313
- npm_command: string;
314
- LC_PAPER: string;
315
- MANPATH: string;
316
- VTE_VERSION: string;
317
- INIT_CWD: string;
318
- EDITOR: string;
319
- NODE_ENV: string;
320
  [key: `PUBLIC_${string}`]: undefined;
321
  [key: `${string}`]: string | undefined;
322
  }
 
51
  export const PARQUET_EXPORT_SECRET: string;
52
  export const RATE_LIMIT: string;
53
  export const MESSAGES_BEFORE_LOGIN: string;
54
+ export const ACSetupSvcPort: string;
55
+ export const ACSvcPort: string;
56
+ export const ALLUSERSPROFILE: string;
57
+ export const APPDATA: string;
58
+ export const CHROME_CRASHPAD_PIPE_NAME: string;
59
+ export const COLOR: string;
60
+ export const COLORTERM: string;
61
+ export const CommonProgramFiles: string;
62
+ export const CommonProgramW6432: string;
63
+ export const COMPUTERNAME: string;
64
+ export const ComSpec: string;
65
+ export const DriverData: string;
66
+ export const EDITOR: string;
67
+ export const EFC_47272: string;
68
+ export const EnableLog: string;
69
  export const GIT_ASKPASS: string;
 
 
 
70
  export const HOME: string;
71
+ export const HOMEDRIVE: string;
72
+ export const HOMEPATH: string;
73
+ export const INIT_CWD: string;
74
+ export const LANG: string;
75
+ export const LOCALAPPDATA: string;
76
+ export const LOGONSERVER: string;
77
+ export const NODE: string;
78
+ export const NODE_ENV: string;
79
+ export const NODE_EXE: string;
80
+ export const NPM_CLI_JS: string;
81
+ export const npm_command: string;
82
+ export const npm_config_cache: string;
 
 
 
 
 
83
  export const npm_config_engine_strict: string;
84
+ export const npm_config_globalconfig: string;
85
+ export const npm_config_global_prefix: string;
86
+ export const npm_config_init_module: string;
87
+ export const npm_config_local_prefix: string;
88
  export const npm_config_metrics_registry: string;
 
 
 
 
 
 
 
 
 
 
 
89
  export const npm_config_node_gyp: string;
90
+ export const npm_config_noproxy: string;
91
+ export const npm_config_prefix: string;
92
+ export const npm_config_userconfig: string;
93
+ export const npm_config_user_agent: string;
94
+ export const npm_execpath: string;
95
+ export const npm_lifecycle_event: string;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  export const npm_lifecycle_script: string;
97
+ export const npm_node_execpath: string;
98
+ export const npm_package_json: string;
99
+ export const npm_package_name: string;
 
 
100
  export const npm_package_version: string;
101
+ export const NPM_PREFIX_NPM_CLI_JS: string;
102
+ export const NUMBER_OF_PROCESSORS: string;
103
+ export const OculusBase: string;
104
+ export const OneDrive: string;
105
+ export const OneDriveConsumer: string;
106
+ export const ORIGINAL_XDG_CURRENT_DESKTOP: string;
107
+ export const OS: string;
108
+ export const Path: string;
109
+ export const PATHEXT: string;
110
+ export const PROCESSOR_ARCHITECTURE: string;
111
+ export const PROCESSOR_IDENTIFIER: string;
112
+ export const PROCESSOR_LEVEL: string;
113
+ export const PROCESSOR_REVISION: string;
114
+ export const ProgramData: string;
115
+ export const ProgramFiles: string;
116
+ export const ProgramW6432: string;
117
+ export const PROMPT: string;
118
+ export const PSModulePath: string;
119
+ export const PUBLIC: string;
120
+ export const RlsSvcPort: string;
121
+ export const SESSIONNAME: string;
122
+ export const SystemDrive: string;
123
+ export const SystemRoot: string;
124
+ export const TEMP: string;
125
+ export const TERM_PROGRAM: string;
126
+ export const TERM_PROGRAM_VERSION: string;
127
+ export const TMP: string;
128
+ export const USERDOMAIN: string;
129
+ export const USERDOMAIN_ROAMINGPROFILE: string;
130
+ export const USERNAME: string;
131
+ export const USERPROFILE: string;
132
  export const VSCODE_GIT_ASKPASS_EXTRA_ARGS: string;
133
+ export const VSCODE_GIT_ASKPASS_MAIN: string;
134
+ export const VSCODE_GIT_ASKPASS_NODE: string;
135
+ export const VSCODE_GIT_IPC_HANDLE: string;
136
+ export const VSCODE_INJECTION: string;
137
+ export const VSCODE_NONCE: string;
138
+ export const windir: string;
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
  /**
 
200
  PARQUET_EXPORT_SECRET: string;
201
  RATE_LIMIT: string;
202
  MESSAGES_BEFORE_LOGIN: string;
203
+ ACSetupSvcPort: string;
204
+ ACSvcPort: string;
205
+ ALLUSERSPROFILE: string;
206
+ APPDATA: string;
207
+ CHROME_CRASHPAD_PIPE_NAME: string;
208
+ COLOR: string;
209
+ COLORTERM: string;
210
+ CommonProgramFiles: string;
211
+ CommonProgramW6432: string;
212
+ COMPUTERNAME: string;
213
+ ComSpec: string;
214
+ DriverData: string;
215
+ EDITOR: string;
216
+ EFC_47272: string;
217
+ EnableLog: string;
218
  GIT_ASKPASS: string;
 
 
 
219
  HOME: string;
220
+ HOMEDRIVE: string;
221
+ HOMEPATH: string;
222
+ INIT_CWD: string;
223
+ LANG: string;
224
+ LOCALAPPDATA: string;
225
+ LOGONSERVER: string;
226
+ NODE: string;
227
+ NODE_ENV: string;
228
+ NODE_EXE: string;
229
+ NPM_CLI_JS: string;
230
+ npm_command: string;
231
+ npm_config_cache: string;
 
 
 
 
 
232
  npm_config_engine_strict: string;
233
+ npm_config_globalconfig: string;
234
+ npm_config_global_prefix: string;
235
+ npm_config_init_module: string;
236
+ npm_config_local_prefix: string;
237
  npm_config_metrics_registry: string;
 
 
 
 
 
 
 
 
 
 
 
238
  npm_config_node_gyp: string;
239
+ npm_config_noproxy: string;
240
+ npm_config_prefix: string;
241
+ npm_config_userconfig: string;
242
+ npm_config_user_agent: string;
243
+ npm_execpath: string;
244
+ npm_lifecycle_event: string;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  npm_lifecycle_script: string;
246
+ npm_node_execpath: string;
247
+ npm_package_json: string;
248
+ npm_package_name: string;
 
 
249
  npm_package_version: string;
250
+ NPM_PREFIX_NPM_CLI_JS: string;
251
+ NUMBER_OF_PROCESSORS: string;
252
+ OculusBase: string;
253
+ OneDrive: string;
254
+ OneDriveConsumer: string;
255
+ ORIGINAL_XDG_CURRENT_DESKTOP: string;
256
+ OS: string;
257
+ Path: string;
258
+ PATHEXT: string;
259
+ PROCESSOR_ARCHITECTURE: string;
260
+ PROCESSOR_IDENTIFIER: string;
261
+ PROCESSOR_LEVEL: string;
262
+ PROCESSOR_REVISION: string;
263
+ ProgramData: string;
264
+ ProgramFiles: string;
265
+ ProgramW6432: string;
266
+ PROMPT: string;
267
+ PSModulePath: string;
268
+ PUBLIC: string;
269
+ RlsSvcPort: string;
270
+ SESSIONNAME: string;
271
+ SystemDrive: string;
272
+ SystemRoot: string;
273
+ TEMP: string;
274
+ TERM_PROGRAM: string;
275
+ TERM_PROGRAM_VERSION: string;
276
+ TMP: string;
277
+ USERDOMAIN: string;
278
+ USERDOMAIN_ROAMINGPROFILE: string;
279
+ USERNAME: string;
280
+ USERPROFILE: string;
281
  VSCODE_GIT_ASKPASS_EXTRA_ARGS: string;
282
+ VSCODE_GIT_ASKPASS_MAIN: string;
283
+ VSCODE_GIT_ASKPASS_NODE: string;
284
+ VSCODE_GIT_IPC_HANDLE: string;
285
+ VSCODE_INJECTION: string;
286
+ VSCODE_NONCE: string;
287
+ windir: string;
 
 
 
 
 
 
 
 
 
 
 
 
288
  [key: `PUBLIC_${string}`]: undefined;
289
  [key: `${string}`]: string | undefined;
290
  }
.svelte-kit/generated/server/internal.js CHANGED
@@ -17,10 +17,10 @@ export const options = {
17
  root,
18
  service_worker: false,
19
  templates: {
20
- app: ({ head, body, assets, nonce, env }) => "<!DOCTYPE html>\n<html lang=\"en\" class=\"h-full\">\n\t<link rel=\"stylesheet\" href=\"https://www.w3schools.com/w3css/4/w3.css\" />\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\" />\n\t\t<script>\n\t\t\tif (\n\t\t\t\tlocalStorage.theme === \"dark\" ||\n\t\t\t\t(!(\"theme\" in localStorage) && window.matchMedia(\"(prefers-color-scheme: dark)\").matches)\n\t\t\t) {\n\t\t\t\tdocument.documentElement.classList.add(\"dark\");\n\t\t\t}\n\n\t\t\t// For some reason, Sveltekit doesn't let us load env variables from .env here, so we load it from hooks.server.ts\n\t\t\twindow.gaId = \"%gaId%\";\n\t\t\twindow.gaIdDeprecated = \"%gaIdDeprecated%\";\n\t\t</script>\n\t\t" + head + "\n\t</head>\n\t<body data-sveltekit-preload-data=\"hover\" class=\"h-full dark:bg-gray-900\">\n\t\t<div id=\"app\" class=\"contents h-full\">" + body + "</div>\n\n\t\t<!-- Google Tag Manager -->\n\t\t<script>\n\t\t\tif (window.gaId) {\n\t\t\t\tconst script = document.createElement(\"script\");\n\t\t\t\tscript.src = \"https://www.googletagmanager.com/gtag/js?id=\" + window.gaId;\n\t\t\t\tscript.async = true;\n\t\t\t\tdocument.head.appendChild(script);\n\n\t\t\t\twindow.dataLayer = window.dataLayer || [];\n\t\t\t\tfunction gtag() {\n\t\t\t\t\tdataLayer.push(arguments);\n\t\t\t\t}\n\t\t\t\tgtag(\"js\", new Date());\n\t\t\t\t/// ^ See https://developers.google.com/tag-platform/gtagjs/install\n\t\t\t\tgtag(\"config\", window.gaId);\n\t\t\t\tgtag(\"consent\", \"default\", { ad_storage: \"denied\", analytics_storage: \"denied\" });\n\t\t\t\t/// ^ See https://developers.google.com/tag-platform/gtagjs/reference#consent\n\t\t\t\t/// TODO: ask the user for their consent and update this with gtag('consent', 'update')\n\t\t\t}\n\t\t</script>\n\n\t\t<!-- Google Analytics v3 (deprecated on 1 July 2023) -->\n\t\t<script>\n\t\t\tif (window.gaIdDeprecated) {\n\t\t\t\t(function (i, s, o, g, r, a, m) {\n\t\t\t\t\ti[\"GoogleAnalyticsObject\"] = r;\n\t\t\t\t\t(i[r] =\n\t\t\t\t\t\ti[r] ||\n\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\t(i[r].q = i[r].q || []).push(arguments);\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t(i[r].l = 1 * new Date());\n\t\t\t\t\t(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);\n\t\t\t\t\ta.async = 1;\n\t\t\t\t\ta.src = g;\n\t\t\t\t\tm.parentNode.insertBefore(a, m);\n\t\t\t\t})(\n\t\t\t\t\twindow,\n\t\t\t\t\tdocument,\n\t\t\t\t\t\"script\",\n\t\t\t\t\t\"https://www.google-analytics.com/analytics.js\",\n\t\t\t\t\t\"ganalytics\"\n\t\t\t\t);\n\t\t\t\tganalytics(\"create\", window.gaIdDeprecated, \"auto\");\n\t\t\t\tganalytics(\"send\", \"pageview\");\n\t\t\t}\n\t\t</script>\n\t</body>\n</html>\n",
21
  error: ({ status, message }) => "<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>" + message + "</title>\n\n\t\t<style>\n\t\t\tbody {\n\t\t\t\t--bg: white;\n\t\t\t\t--fg: #222;\n\t\t\t\t--divider: #ccc;\n\t\t\t\tbackground: var(--bg);\n\t\t\t\tcolor: var(--fg);\n\t\t\t\tfont-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,\n\t\t\t\t\tUbuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t.error {\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tmax-width: 32rem;\n\t\t\t\tmargin: 0 1rem;\n\t\t\t}\n\n\t\t\t.status {\n\t\t\t\tfont-weight: 200;\n\t\t\t\tfont-size: 3rem;\n\t\t\t\tline-height: 1;\n\t\t\t\tposition: relative;\n\t\t\t\ttop: -0.05rem;\n\t\t\t}\n\n\t\t\t.message {\n\t\t\t\tborder-left: 1px solid var(--divider);\n\t\t\t\tpadding: 0 0 0 1rem;\n\t\t\t\tmargin: 0 0 0 1rem;\n\t\t\t\tmin-height: 2.5rem;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t}\n\n\t\t\t.message h1 {\n\t\t\t\tfont-weight: 400;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t@media (prefers-color-scheme: dark) {\n\t\t\t\tbody {\n\t\t\t\t\t--bg: #222;\n\t\t\t\t\t--fg: #ddd;\n\t\t\t\t\t--divider: #666;\n\t\t\t\t}\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div class=\"error\">\n\t\t\t<span class=\"status\">" + status + "</span>\n\t\t\t<div class=\"message\">\n\t\t\t\t<h1>" + message + "</h1>\n\t\t\t</div>\n\t\t</div>\n\t</body>\n</html>\n"
22
  },
23
- version_hash: "1ji7gzf"
24
  };
25
 
26
  export function get_hooks() {
 
17
  root,
18
  service_worker: false,
19
  templates: {
20
+ app: ({ head, body, assets, nonce, env }) => "<!DOCTYPE html>\r\n<html lang=\"en\" class=\"h-full\">\r\n\t<link rel=\"stylesheet\" href=\"https://www.w3schools.com/w3css/4/w3.css\" />\r\n\t<head>\r\n\t\t<meta charset=\"utf-8\" />\r\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\" />\r\n\t\t<meta property=\"og:image\" content=\"/chatui/thumbnail.jpg\"/>\r\n\t\t<script>\r\n\t\t\tif (\r\n\t\t\t\tlocalStorage.theme === \"dark\" ||\r\n\t\t\t\t(!(\"theme\" in localStorage) && window.matchMedia(\"(prefers-color-scheme: dark)\").matches)\r\n\t\t\t) {\r\n\t\t\t\tdocument.documentElement.classList.add(\"dark\");\r\n\t\t\t}\r\n\t\t</script>\r\n\t\t" + head + "\r\n\t</head>\r\n\t<body data-sveltekit-preload-data=\"hover\" class=\"h-full dark:bg-gray-900\">\r\n\t\t<div id=\"app\" class=\"contents h-full\">" + body + "</div>\r\n\t</body>\r\n</html>\r\n",
21
  error: ({ status, message }) => "<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>" + message + "</title>\n\n\t\t<style>\n\t\t\tbody {\n\t\t\t\t--bg: white;\n\t\t\t\t--fg: #222;\n\t\t\t\t--divider: #ccc;\n\t\t\t\tbackground: var(--bg);\n\t\t\t\tcolor: var(--fg);\n\t\t\t\tfont-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,\n\t\t\t\t\tUbuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t.error {\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tmax-width: 32rem;\n\t\t\t\tmargin: 0 1rem;\n\t\t\t}\n\n\t\t\t.status {\n\t\t\t\tfont-weight: 200;\n\t\t\t\tfont-size: 3rem;\n\t\t\t\tline-height: 1;\n\t\t\t\tposition: relative;\n\t\t\t\ttop: -0.05rem;\n\t\t\t}\n\n\t\t\t.message {\n\t\t\t\tborder-left: 1px solid var(--divider);\n\t\t\t\tpadding: 0 0 0 1rem;\n\t\t\t\tmargin: 0 0 0 1rem;\n\t\t\t\tmin-height: 2.5rem;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t}\n\n\t\t\t.message h1 {\n\t\t\t\tfont-weight: 400;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t@media (prefers-color-scheme: dark) {\n\t\t\t\tbody {\n\t\t\t\t\t--bg: #222;\n\t\t\t\t\t--fg: #ddd;\n\t\t\t\t\t--divider: #666;\n\t\t\t\t}\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div class=\"error\">\n\t\t\t<span class=\"status\">" + status + "</span>\n\t\t\t<div class=\"message\">\n\t\t\t\t<h1>" + message + "</h1>\n\t\t\t</div>\n\t\t</div>\n\t</body>\n</html>\n"
22
  },
23
+ version_hash: "aw3qnn"
24
  };
25
 
26
  export function get_hooks() {
.svelte-kit/types/src/routes/proxy+layout.server.ts CHANGED
@@ -29,7 +29,6 @@ export const load = async ({ locals, depends, url }: Parameters<LayoutServerLoad
29
  throw redirect(302, url.pathname);
30
  }
31
 
32
-
33
  return {
34
  conversations: [],
35
  settings: {
@@ -46,6 +45,8 @@ export const load = async ({ locals, depends, url }: Parameters<LayoutServerLoad
46
  websiteUrl: model.websiteUrl,
47
  modelUrl: model.modelUrl,
48
  is_local: model.is_local,
 
 
49
  datasetName: model.datasetName,
50
  datasetUrl: model.datasetUrl,
51
  displayName: model.displayName,
 
29
  throw redirect(302, url.pathname);
30
  }
31
 
 
32
  return {
33
  conversations: [],
34
  settings: {
 
45
  websiteUrl: model.websiteUrl,
46
  modelUrl: model.modelUrl,
47
  is_local: model.is_local,
48
+ is_code: model.is_code,
49
+ type: model.type,
50
  datasetName: model.datasetName,
51
  datasetUrl: model.datasetUrl,
52
  displayName: model.displayName,
PRIVACY.md CHANGED
@@ -15,4 +15,3 @@ BlindChat is an open-source project to provide fully in-browser and private Conv
15
  It is currently developed and maintained by [Mithril Security](https://www.mithrilsecurity.io/), a startup aiming to make AI more private.
16
 
17
  You can find more information on our [Github](https://github.com/mithril-security/blind_chat/), join us on our [Discord](https://discord.com/invite/TxEHagpWd4), or directly [contact us](mailto:contact@mithrilsecurity.io).
18
-
 
15
  It is currently developed and maintained by [Mithril Security](https://www.mithrilsecurity.io/), a startup aiming to make AI more private.
16
 
17
  You can find more information on our [Github](https://github.com/mithril-security/blind_chat/), join us on our [Discord](https://discord.com/invite/TxEHagpWd4), or directly [contact us](mailto:contact@mithrilsecurity.io).
 
README.md CHANGED
@@ -8,4 +8,4 @@ pinned: false
8
  app_port: 3000
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
8
  app_port: 3000
9
  ---
10
 
11
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
src/app.html CHANGED
@@ -4,6 +4,7 @@
4
  <head>
5
  <meta charset="utf-8" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
 
7
  <script>
8
  if (
9
  localStorage.theme === "dark" ||
@@ -11,62 +12,10 @@
11
  ) {
12
  document.documentElement.classList.add("dark");
13
  }
14
-
15
- // For some reason, Sveltekit doesn't let us load env variables from .env here, so we load it from hooks.server.ts
16
- window.gaId = "%gaId%";
17
- window.gaIdDeprecated = "%gaIdDeprecated%";
18
  </script>
19
  %sveltekit.head%
20
  </head>
21
  <body data-sveltekit-preload-data="hover" class="h-full dark:bg-gray-900">
22
  <div id="app" class="contents h-full">%sveltekit.body%</div>
23
-
24
- <!-- Google Tag Manager -->
25
- <script>
26
- if (window.gaId) {
27
- const script = document.createElement("script");
28
- script.src = "https://www.googletagmanager.com/gtag/js?id=" + window.gaId;
29
- script.async = true;
30
- document.head.appendChild(script);
31
-
32
- window.dataLayer = window.dataLayer || [];
33
- function gtag() {
34
- dataLayer.push(arguments);
35
- }
36
- gtag("js", new Date());
37
- /// ^ See https://developers.google.com/tag-platform/gtagjs/install
38
- gtag("config", window.gaId);
39
- gtag("consent", "default", { ad_storage: "denied", analytics_storage: "denied" });
40
- /// ^ See https://developers.google.com/tag-platform/gtagjs/reference#consent
41
- /// TODO: ask the user for their consent and update this with gtag('consent', 'update')
42
- }
43
- </script>
44
-
45
- <!-- Google Analytics v3 (deprecated on 1 July 2023) -->
46
- <script>
47
- if (window.gaIdDeprecated) {
48
- (function (i, s, o, g, r, a, m) {
49
- i["GoogleAnalyticsObject"] = r;
50
- (i[r] =
51
- i[r] ||
52
- function () {
53
- (i[r].q = i[r].q || []).push(arguments);
54
- }),
55
- (i[r].l = 1 * new Date());
56
- (a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
57
- a.async = 1;
58
- a.src = g;
59
- m.parentNode.insertBefore(a, m);
60
- })(
61
- window,
62
- document,
63
- "script",
64
- "https://www.google-analytics.com/analytics.js",
65
- "ganalytics"
66
- );
67
- ganalytics("create", window.gaIdDeprecated, "auto");
68
- ganalytics("send", "pageview");
69
- }
70
- </script>
71
  </body>
72
  </html>
 
4
  <head>
5
  <meta charset="utf-8" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
7
+ <meta property="og:image" content="/chatui/thumbnail.jpg" />
8
  <script>
9
  if (
10
  localStorage.theme === "dark" ||
 
12
  ) {
13
  document.documentElement.classList.add("dark");
14
  }
 
 
 
 
15
  </script>
16
  %sveltekit.head%
17
  </head>
18
  <body data-sveltekit-preload-data="hover" class="h-full dark:bg-gray-900">
19
  <div id="app" class="contents h-full">%sveltekit.body%</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  </body>
21
  </html>
src/hooks.server.ts CHANGED
@@ -53,37 +53,37 @@ export const handle: Handle = async ({ event, resolve }) => {
53
  }
54
  }
55
 
56
- if (
57
- !event.url.pathname.startsWith(`${base}/login`) &&
58
- !event.url.pathname.startsWith(`${base}/admin`) &&
59
- !["GET", "OPTIONS", "HEAD"].includes(event.request.method)
60
- ) {
61
- if (
62
- !user &&
63
- requiresUser &&
64
- !((MESSAGES_BEFORE_LOGIN ? parseInt(MESSAGES_BEFORE_LOGIN) : 0) > 0)
65
- ) {
66
- return errorResponse(401, ERROR_MESSAGES.authOnly);
67
- }
68
 
69
- // if login is not required and the call is not from /settings and we display the ethics modal with PUBLIC_APP_DISCLAIMER
70
- // we check if the user has accepted the ethics modal first.
71
- // If login is required, `ethicsModalAcceptedAt` is already true at this point, so do not pass this condition. This saves a DB call.
72
- if (
73
- !requiresUser &&
74
- !event.url.pathname.startsWith(`${base}/settings`) &&
75
- !!PUBLIC_APP_DISCLAIMER
76
- ) {
77
- const hasAcceptedEthicsModal = await collections.settings.countDocuments({
78
- sessionId: event.locals.sessionId,
79
- ethicsModalAcceptedAt: { $exists: true },
80
- });
81
 
82
- if (!hasAcceptedEthicsModal) {
83
- return errorResponse(405, "You need to accept the welcome modal first");
84
- }
85
- }
86
- }
87
 
88
  refreshSessionCookie(event.cookies, event.locals.sessionId);
89
 
 
53
  }
54
  }
55
 
56
+ // if (
57
+ // !event.url.pathname.startsWith(`${base}/login`) &&
58
+ // !event.url.pathname.startsWith(`${base}/admin`) &&
59
+ // !["GET", "OPTIONS", "HEAD"].includes(event.request.method)
60
+ // ) {
61
+ // if (
62
+ // !user &&
63
+ // requiresUser &&
64
+ // !((MESSAGES_BEFORE_LOGIN ? parseInt(MESSAGES_BEFORE_LOGIN) : 0) > 0)
65
+ // ) {
66
+ // return errorResponse(401, ERROR_MESSAGES.authOnly);
67
+ // }
68
 
69
+ // // if login is not required and the call is not from /settings and we display the ethics modal with PUBLIC_APP_DISCLAIMER
70
+ // // we check if the user has accepted the ethics modal first.
71
+ // // If login is required, `ethicsModalAcceptedAt` is already true at this point, so do not pass this condition. This saves a DB call.
72
+ // if (
73
+ // !requiresUser &&
74
+ // !event.url.pathname.startsWith(`${base}/settings`) &&
75
+ // !!PUBLIC_APP_DISCLAIMER
76
+ // ) {
77
+ // const hasAcceptedEthicsModal = await collections.settings.countDocuments({
78
+ // sessionId: event.locals.sessionId,
79
+ // ethicsModalAcceptedAt: { $exists: true },
80
+ // });
81
 
82
+ // if (!hasAcceptedEthicsModal) {
83
+ // return errorResponse(405, "You need to accept the welcome modal first");
84
+ // }
85
+ // }
86
+ // }
87
 
88
  refreshSessionCookie(event.cookies, event.locals.sessionId);
89
 
src/lib/components/ConfirmModal.svelte CHANGED
@@ -8,20 +8,22 @@
8
 
9
  <Modal>
10
  <div class="flex w-full flex-col gap-0 p-2">
11
- <div class="flex items-start text-xl font-bold text-gray-800 m-2">
12
  <h1>You are about to download an AI model on your device</h1>
13
  <br />
14
  <button type="button" class="group" on:click={() => dispatch("close")}>
15
  <CarbonClose class="text-gray-900 group-hover:text-gray-500" />
16
  </button>
17
  </div>
18
- <div class="flex items-start text-m text-gray-800 m-2">
19
- <br>To ensure your conversations with our AI remain private, our web application sends a model to your device to perform inference locally. No data leaves your device.<br />
20
- <br>This might be demanding in terms of bandwidth, storage and computing power on your side.<br />
 
 
21
  <br />
22
  </div>
23
- <div class="flex items-start text-m text-gray-800 m-2">
24
- <br><b>Mobile usage is not advised.</b><br />
25
  </div>
26
  <br />
27
  </div>
 
8
 
9
  <Modal>
10
  <div class="flex w-full flex-col gap-0 p-2">
11
+ <div class="m-2 flex items-start text-xl font-bold text-gray-800">
12
  <h1>You are about to download an AI model on your device</h1>
13
  <br />
14
  <button type="button" class="group" on:click={() => dispatch("close")}>
15
  <CarbonClose class="text-gray-900 group-hover:text-gray-500" />
16
  </button>
17
  </div>
18
+ <div class="text-m m-2 flex items-start text-gray-800">
19
+ <br />To ensure your conversations with our AI remain private, our web application sends a
20
+ model to your device to perform inference locally. No data leaves your device.<br />
21
+ <br />This might be demanding in terms of bandwidth, storage and computing power on your side.<br
22
+ />
23
  <br />
24
  </div>
25
+ <div class="text-m m-2 flex items-start text-gray-800">
26
+ <br /><b>Mobile usage is not advised.</b><br />
27
  </div>
28
  <br />
29
  </div>
src/lib/components/LoadingModal.svelte CHANGED
@@ -23,8 +23,8 @@
23
  <h2>Loading the model...</h2>
24
  <br />
25
  </div>
26
- <div class="flex items-start text-s text-gray-800">
27
- <br>Please wait while we download the model. This has to be done only once.
28
  </div>
29
  <br />
30
  {#await forceUpdate(pr) then _}
 
23
  <h2>Loading the model...</h2>
24
  <br />
25
  </div>
26
+ <div class="text-s flex items-start text-gray-800">
27
+ <br />Please wait while we download the model. This has to be done only once.
28
  </div>
29
  <br />
30
  {#await forceUpdate(pr) then _}
src/lib/components/LoginModal.svelte CHANGED
@@ -14,7 +14,7 @@
14
 
15
  <Modal>
16
  <div
17
- class="flex w-full flex-col items-center gap-6 bg-gradient-to-t from-primary-500/40 via-primary-500/10 to-primary-500/0 px-4 pb-10 pt-9 text-center "
18
  >
19
  <h2 class="flex items-center text-2xl font-semibold text-gray-800">
20
  <Logo classNames="mr-1" />
 
14
 
15
  <Modal>
16
  <div
17
+ class="flex w-full flex-col items-center gap-6 bg-gradient-to-t from-primary-500/40 via-primary-500/10 to-primary-500/0 px-4 pb-10 pt-9 text-center"
18
  >
19
  <h2 class="flex items-center text-2xl font-semibold text-gray-800">
20
  <Logo classNames="mr-1" />
src/lib/components/ModelCardMetadata.svelte CHANGED
@@ -9,7 +9,7 @@
9
  </script>
10
 
11
  <div
12
- class="flex items-center gap-5 rounded-xl bg-gray-100 px-3 py-2 text-sm
13
  {variant === 'dark'
14
  ? 'text-gray-600 dark:bg-gray-800 dark:text-gray-300'
15
  : 'text-gray-800 dark:bg-gray-100 dark:text-gray-600'}"
 
9
  </script>
10
 
11
  <div
12
+ class="flex items-center gap-5 rounded-xl bg-gray-100 px-3 py-2 text-sm
13
  {variant === 'dark'
14
  ? 'text-gray-600 dark:bg-gray-800 dark:text-gray-300'
15
  : 'text-gray-800 dark:bg-gray-100 dark:text-gray-600'}"
src/lib/components/ModelsModal.svelte CHANGED
@@ -13,13 +13,20 @@
13
  import CarbonEdit from "~icons/carbon/edit";
14
  import CarbonSave from "~icons/carbon/save";
15
  import CarbonRestart from "~icons/carbon/restart";
 
16
 
17
  export let settings: LayoutData["settings"];
18
  export let models: Array<Model>;
19
 
20
- let selectedModelId = settings.activeModel;
 
21
 
22
- const dispatch = createEventDispatcher<{ close: void }>();
 
 
 
 
 
23
 
24
  let expanded = false;
25
 
@@ -30,6 +37,11 @@
30
  expanded = !expanded;
31
  }
32
 
 
 
 
 
 
33
  let value = "";
34
 
35
  function onModelChange() {
@@ -37,6 +49,7 @@
37
  settings.customPrompts[selectedModelId] ??
38
  models.filter((el) => el.id === selectedModelId)[0].preprompt ??
39
  "";
 
40
  }
41
 
42
  $: selectedModelId, onModelChange();
@@ -44,16 +57,11 @@
44
 
45
  <Modal width="max-w-lg" on:close>
46
  <form
47
- action="{base}/settings"
48
- method="post"
49
  on:submit={() => {
50
  if (expanded) {
51
  onToggle();
52
  }
53
  }}
54
- use:enhance={() => {
55
- dispatch("close");
56
- }}
57
  class="flex w-full flex-col gap-5 p-6"
58
  >
59
  {#each Object.entries(settings).filter(([k]) => !(k == "activeModel" || k === "customPrompts")) as [key, val]}
@@ -129,7 +137,7 @@
129
  enterkeyhint="send"
130
  tabindex="0"
131
  rows="1"
132
- class="h-20 w-full resize-none scroll-p-3 overflow-x-hidden overflow-y-scroll rounded-md border border-gray-300 bg-transparent p-1 text-xs outline-none focus:ring-0 focus-visible:ring-0"
133
  bind:value
134
  hidden={!expanded}
135
  />
@@ -140,8 +148,12 @@
140
  {/each}
141
  </div>
142
  <button
143
- type="submit"
144
  class="mt-2 rounded-full bg-black px-5 py-2 text-lg font-semibold text-gray-100 ring-gray-400 ring-offset-1 transition-colors hover:ring"
 
 
 
 
145
  >
146
  Apply
147
  </button>
 
13
  import CarbonEdit from "~icons/carbon/edit";
14
  import CarbonSave from "~icons/carbon/save";
15
  import CarbonRestart from "~icons/carbon/restart";
16
+ import { curr_model_writable } from "../../routes/LayoutWritable";
17
 
18
  export let settings: LayoutData["settings"];
19
  export let models: Array<Model>;
20
 
21
+ let selectedModelId = "";
22
+ let selectedNum = 0;
23
 
24
+ curr_model_writable.subscribe((val) => {
25
+ selectedModelId = models[val].name;
26
+ selectedNum = val;
27
+ });
28
+
29
+ const dispatch = createEventDispatcher<{ close: void; closeAndSave }>();
30
 
31
  let expanded = false;
32
 
 
37
  expanded = !expanded;
38
  }
39
 
40
+ function onApply() {
41
+ curr_model_writable.set(selectedNum);
42
+ dispatch("close");
43
+ }
44
+
45
  let value = "";
46
 
47
  function onModelChange() {
 
49
  settings.customPrompts[selectedModelId] ??
50
  models.filter((el) => el.id === selectedModelId)[0].preprompt ??
51
  "";
52
+ selectedNum = models.findIndex((el) => el.id == selectedModelId);
53
  }
54
 
55
  $: selectedModelId, onModelChange();
 
57
 
58
  <Modal width="max-w-lg" on:close>
59
  <form
 
 
60
  on:submit={() => {
61
  if (expanded) {
62
  onToggle();
63
  }
64
  }}
 
 
 
65
  class="flex w-full flex-col gap-5 p-6"
66
  >
67
  {#each Object.entries(settings).filter(([k]) => !(k == "activeModel" || k === "customPrompts")) as [key, val]}
 
137
  enterkeyhint="send"
138
  tabindex="0"
139
  rows="1"
140
+ class="h-20 w-full resize-none scroll-p-3 overflow-x-hidden overflow-y-scroll rounded-md border border-gray-300 bg-transparent p-1 text-xs outline-none focus:ring-0 focus-visible:ring-0"
141
  bind:value
142
  hidden={!expanded}
143
  />
 
148
  {/each}
149
  </div>
150
  <button
151
+ type="button"
152
  class="mt-2 rounded-full bg-black px-5 py-2 text-lg font-semibold text-gray-100 ring-gray-400 ring-offset-1 transition-colors hover:ring"
153
+ on:click={() =>
154
+ dispatch("closeAndSave", {
155
+ id: selectedNum,
156
+ })}
157
  >
158
  Apply
159
  </button>
src/lib/components/NavConversationItem.svelte CHANGED
@@ -24,7 +24,9 @@
24
  on:mouseleave={() => {
25
  confirmDelete = false;
26
  }}
27
- on:click = {() => {params_writable.set(conv.id)}}
 
 
28
  href="{base}/conversation/{conv.id}"
29
  class="group flex h-11 flex-none items-center gap-1.5 rounded-lg pl-3 pr-2 text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700 {conv.id ===
30
  $page.params.id
 
24
  on:mouseleave={() => {
25
  confirmDelete = false;
26
  }}
27
+ on:click={() => {
28
+ params_writable.set(conv.id);
29
+ }}
30
  href="{base}/conversation/{conv.id}"
31
  class="group flex h-11 flex-none items-center gap-1.5 rounded-lg pl-3 pr-2 text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700 {conv.id ===
32
  $page.params.id
src/lib/components/SettingsModal.svelte CHANGED
@@ -14,7 +14,7 @@
14
 
15
  let isConfirmingDeletion = false;
16
 
17
- const dispatch = createEventDispatcher<{ close: void, deleteAllConversations: void }>();
18
  </script>
19
 
20
  <Modal on:close>
@@ -33,16 +33,14 @@
33
  method="post"
34
  action="{base}/settings"
35
  >
36
- <form
37
- on:submit|preventDefault={() => (isConfirmingDeletion = true)}
38
- >
39
  <button type="submit" class="underline decoration-gray-300 hover:decoration-gray-700">
40
  Delete all conversations
41
  </button>
42
  </form>
43
  <button
44
  type="submit"
45
- class="mt-2 rounded-full bg-black px-5 py-2 text-lg font-semibold text-gray-100 ring-gray-400 ring-offset-1 transition-all focus-visible:outline-none focus-visible:ring hover:ring"
46
  >
47
  Apply
48
  </button>
@@ -50,14 +48,7 @@
50
 
51
  {#if isConfirmingDeletion}
52
  <Modal on:close={() => (isConfirmingDeletion = false)}>
53
- <form
54
- use:enhance={() => {
55
- dispatch("close");
56
- }}
57
- method="post"
58
- action="{base}/conversations?/delete"
59
- class="flex w-full flex-col gap-5 p-6"
60
- >
61
  <div class="flex items-start justify-between text-xl font-semibold text-gray-800">
62
  <h2>Are you sure?</h2>
63
  <button type="button" class="group" on:click={() => (isConfirmingDeletion = false)}>
@@ -68,8 +59,9 @@
68
  This action will delete all your conversations. This cannot be undone.
69
  </p>
70
  <button
71
- type="submit"
72
- class="mt-2 rounded-full bg-red-700 px-5 py-2 text-lg font-semibold text-gray-100 ring-gray-400 ring-offset-1 transition-all focus-visible:outline-none focus-visible:ring hover:ring"
 
73
  >
74
  Confirm deletion
75
  </button>
 
14
 
15
  let isConfirmingDeletion = false;
16
 
17
+ const dispatch = createEventDispatcher<{ close: void; deleteAllConversations: void }>();
18
  </script>
19
 
20
  <Modal on:close>
 
33
  method="post"
34
  action="{base}/settings"
35
  >
36
+ <form on:submit|preventDefault={() => (isConfirmingDeletion = true)}>
 
 
37
  <button type="submit" class="underline decoration-gray-300 hover:decoration-gray-700">
38
  Delete all conversations
39
  </button>
40
  </form>
41
  <button
42
  type="submit"
43
+ class="mt-2 rounded-full bg-black px-5 py-2 text-lg font-semibold text-gray-100 ring-gray-400 ring-offset-1 transition-all hover:ring focus-visible:outline-none focus-visible:ring"
44
  >
45
  Apply
46
  </button>
 
48
 
49
  {#if isConfirmingDeletion}
50
  <Modal on:close={() => (isConfirmingDeletion = false)}>
51
+ <form class="flex w-full flex-col gap-5 p-6">
 
 
 
 
 
 
 
52
  <div class="flex items-start justify-between text-xl font-semibold text-gray-800">
53
  <h2>Are you sure?</h2>
54
  <button type="button" class="group" on:click={() => (isConfirmingDeletion = false)}>
 
59
  This action will delete all your conversations. This cannot be undone.
60
  </p>
61
  <button
62
+ type="button"
63
+ class="mt-2 rounded-full bg-red-700 px-5 py-2 text-lg font-semibold text-gray-100 ring-gray-400 ring-offset-1 transition-all hover:ring focus-visible:outline-none focus-visible:ring"
64
+ on:click={() => dispatch("deleteAllConversations")}
65
  >
66
  Confirm deletion
67
  </button>
src/lib/components/Tooltip.svelte CHANGED
@@ -6,7 +6,7 @@
6
 
7
  <div
8
  class="
9
- pointer-events-none absolute rounded bg-black px-2 py-1 font-normal leading-tight text-white shadow transition-opacity
10
  {position}
11
  {classNames}
12
  "
 
6
 
7
  <div
8
  class="
9
+ pointer-events-none absolute rounded bg-black px-2 py-1 font-normal leading-tight text-white shadow transition-opacity
10
  {position}
11
  {classNames}
12
  "
src/lib/components/chat/ChatIntroduction.svelte CHANGED
@@ -12,14 +12,20 @@
12
  import type { LayoutData } from "../../../routes/$types";
13
  import { findCurrentModel } from "$lib/utils/models";
14
  import { env } from "$env/dynamic/public";
 
15
 
16
  export let currentModel: Model;
17
  export let settings: LayoutData["settings"];
18
  export let models: Model[];
19
 
20
  let isModelsModalOpen = false;
 
21
 
22
- $: currentModelMetadata = findCurrentModel(models, settings.activeModel);
 
 
 
 
23
 
24
  const announcementBanners = PUBLIC_ANNOUNCEMENT_BANNERS
25
  ? JSON.parse(PUBLIC_ANNOUNCEMENT_BANNERS)
@@ -27,7 +33,7 @@
27
 
28
  const dispatch = createEventDispatcher<{ message: string }>();
29
 
30
- $: title = env.PUBLIC_APP_NAME
31
  </script>
32
 
33
  <div class="my-auto grid gap-8 lg:grid-cols-3">
@@ -49,17 +55,24 @@
49
  </div>
50
  <div class="lg:col-span-2 lg:pl-24">
51
  {#each announcementBanners as banner}
52
- <AnnouncementBanner classNames="mb-4" title={banner.title}>
53
- <a
54
- target="_blank"
55
- href={banner.linkHref}
56
- class="mr-2 flex items-center underline hover:no-underline"
57
- ><CarbonArrowUpRight class="mr-1.5 text-xs" /> {banner.linkTitle}</a
58
- >
59
- </AnnouncementBanner>
60
  {/each}
61
  {#if isModelsModalOpen}
62
- <ModelsModal {settings} {models} on:close={() => (isModelsModalOpen = false)} />
 
 
 
 
 
 
 
63
  {/if}
64
  <div class="overflow-hidden rounded-xl border dark:border-gray-800">
65
  <div class="flex p-3">
 
12
  import type { LayoutData } from "../../../routes/$types";
13
  import { findCurrentModel } from "$lib/utils/models";
14
  import { env } from "$env/dynamic/public";
15
+ import { curr_model_writable } from "../../../routes/LayoutWritable";
16
 
17
  export let currentModel: Model;
18
  export let settings: LayoutData["settings"];
19
  export let models: Model[];
20
 
21
  let isModelsModalOpen = false;
22
+ let selectedNum = 0;
23
 
24
+ curr_model_writable.subscribe((val) => {
25
+ selectedNum = val;
26
+ });
27
+
28
+ $: currentModelMetadata = findCurrentModel(models, models[selectedNum].name);
29
 
30
  const announcementBanners = PUBLIC_ANNOUNCEMENT_BANNERS
31
  ? JSON.parse(PUBLIC_ANNOUNCEMENT_BANNERS)
 
33
 
34
  const dispatch = createEventDispatcher<{ message: string }>();
35
 
36
+ $: title = env.PUBLIC_APP_NAME;
37
  </script>
38
 
39
  <div class="my-auto grid gap-8 lg:grid-cols-3">
 
55
  </div>
56
  <div class="lg:col-span-2 lg:pl-24">
57
  {#each announcementBanners as banner}
58
+ <AnnouncementBanner classNames="mb-4" title={banner.title}>
59
+ <a
60
+ target="_blank"
61
+ href={banner.linkHref}
62
+ class="mr-2 flex items-center underline hover:no-underline"
63
+ ><CarbonArrowUpRight class="mr-1.5 text-xs" /> {banner.linkTitle}</a
64
+ >
65
+ </AnnouncementBanner>
66
  {/each}
67
  {#if isModelsModalOpen}
68
+ <ModelsModal
69
+ {settings}
70
+ {models}
71
+ on:close={() => (isModelsModalOpen = false)}
72
+ on:closeAndSave={(id) => (
73
+ (isModelsModalOpen = false), curr_model_writable.set(id.detail.id)
74
+ )}
75
+ />
76
  {/if}
77
  <div class="overflow-hidden rounded-xl border dark:border-gray-800">
78
  <div class="flex p-3">
src/lib/components/chat/ChatMessage.svelte CHANGED
@@ -37,7 +37,10 @@
37
  return ret;
38
  }
39
  function unsanitizeMd(md: string) {
40
- return md.replaceAll("&lt;", "<");
 
 
 
41
  }
42
 
43
  export let model: Model;
@@ -131,14 +134,12 @@
131
  class="prose max-w-none dark:prose-invert max-sm:prose-sm prose-headings:font-semibold prose-h1:text-lg prose-h2:text-base prose-h3:text-base prose-pre:bg-gray-800 dark:prose-pre:bg-gray-900"
132
  bind:this={contentEl}
133
  >
134
- {#each tokens as token}
135
- {#if token.type === "code"}
136
- <CodeBlock lang={token.lang} code={unsanitizeMd(token.text)} />
137
- {:else}
138
- <!-- eslint-disable-next-line svelte/no-at-html-tags -->
139
- {@html marked(token.raw, options)}
140
- {/if}
141
- {/each}
142
  </div>
143
  </div>
144
  <!-- {#if isAuthor && !loading && message.content}
@@ -184,29 +185,7 @@
184
  {message.content.trim()}
185
  </div>
186
  {#if !loading}
187
- <div class="absolute right-0 top-3.5 flex gap-2 lg:-right-2">
188
- <!-- {#if downloadLink}
189
- <a
190
- class="rounded-lg border border-gray-100 p-1 text-xs text-gray-400 group-hover:block hover:text-gray-500 dark:border-gray-800 dark:text-gray-400 dark:hover:text-gray-300 md:hidden"
191
- title="Download prompt and parameters"
192
- type="button"
193
- target="_blank"
194
- href={downloadLink}
195
- >
196
- <CarbonDownload />
197
- </a>
198
- {/if} -->
199
- <!-- {#if !readOnly}
200
- <button
201
- class="cursor-pointer rounded-lg border border-gray-100 p-1 text-xs text-gray-400 group-hover:block hover:text-gray-500 dark:border-gray-800 dark:text-gray-400 dark:hover:text-gray-300 md:hidden lg:-right-2"
202
- title="Retry"
203
- type="button"
204
- on:click={() => dispatch("retry", { content: message.content, id: message.id })}
205
- >
206
- <CarbonRotate360 />
207
- </button>
208
- {/if} -->
209
- </div>
210
  {/if}
211
  </div>
212
  {/if}
 
37
  return ret;
38
  }
39
  function unsanitizeMd(md: string) {
40
+ if (md != undefined)
41
+ return md.replaceAll("&lt;", "<");
42
+ else
43
+ return ""
44
  }
45
 
46
  export let model: Model;
 
134
  class="prose max-w-none dark:prose-invert max-sm:prose-sm prose-headings:font-semibold prose-h1:text-lg prose-h2:text-base prose-h3:text-base prose-pre:bg-gray-800 dark:prose-pre:bg-gray-900"
135
  bind:this={contentEl}
136
  >
137
+ {#if message.isCode == true}
138
+ <CodeBlock lang={"python"} code={unsanitizeMd(message.content)} />
139
+ {:else}
140
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
141
+ {@html marked(message.content, options)}
142
+ {/if}
 
 
143
  </div>
144
  </div>
145
  <!-- {#if isAuthor && !loading && message.content}
 
185
  {message.content.trim()}
186
  </div>
187
  {#if !loading}
188
+ <div class="absolute right-0 top-3.5 flex gap-2 lg:-right-2" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  {/if}
190
  </div>
191
  {/if}
src/lib/components/chat/ChatWindow.svelte CHANGED
@@ -83,7 +83,7 @@
83
  </div>
84
  <form
85
  on:submit|preventDefault={handleSubmit}
86
- class="relative flex w-full max-w-4xl flex-1 items-center rounded-xl border bg-gray-100 focus-within:border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:focus-within:border-gray-500
87
  {isReadOnly ? 'opacity-30' : ''}"
88
  >
89
  <div class="flex w-full flex-1 border-none bg-transparent">
@@ -100,19 +100,19 @@
100
 
101
  {#if loading}
102
  <button
103
- class="btn mx-1 my-1 inline-block h-[2.4rem] self-end rounded-lg bg-transparent p-1 px-[0.7rem] text-gray-400 disabled:opacity-60 enabled:hover:text-gray-700 dark:disabled:opacity-40 enabled:dark:hover:text-gray-100 md:hidden"
104
  on:click={() => dispatch("stop")}
105
  >
106
  <CarbonStopFilledAlt />
107
  </button>
108
  <div
109
- class="mx-1 my-1 hidden h-[2.4rem] items-center p-1 px-[0.7rem] text-gray-400 disabled:opacity-60 enabled:hover:text-gray-700 dark:disabled:opacity-40 enabled:dark:hover:text-gray-100 md:flex"
110
  >
111
  <EosIconsLoading />
112
  </div>
113
  {:else}
114
  <button
115
- class="btn mx-1 my-1 h-[2.4rem] self-end rounded-lg bg-transparent p-1 px-[0.7rem] text-gray-400 disabled:opacity-60 enabled:hover:text-gray-700 dark:disabled:opacity-40 enabled:dark:hover:text-gray-100"
116
  disabled={!message || isReadOnly}
117
  type="submit"
118
  >
@@ -128,9 +128,9 @@
128
  target="_blank"
129
  rel="noreferrer"
130
  class="hover:underline">{currentModel.displayName}</a
131
- > <span class="max-sm:hidden">·</span><br class="sm:hidden" /> Generated content may be inaccurate
132
- or false.
133
- <br><br> 🔒 All conversations are end-to-end protected
134
  </p>
135
  <!-- {#if messages.length}
136
  <button
 
83
  </div>
84
  <form
85
  on:submit|preventDefault={handleSubmit}
86
+ class="relative flex w-full max-w-4xl flex-1 items-center rounded-xl border bg-gray-100 focus-within:border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:focus-within:border-gray-500
87
  {isReadOnly ? 'opacity-30' : ''}"
88
  >
89
  <div class="flex w-full flex-1 border-none bg-transparent">
 
100
 
101
  {#if loading}
102
  <button
103
+ class="btn mx-1 my-1 inline-block h-[2.4rem] self-end rounded-lg bg-transparent p-1 px-[0.7rem] text-gray-400 enabled:hover:text-gray-700 disabled:opacity-60 enabled:dark:hover:text-gray-100 dark:disabled:opacity-40 md:hidden"
104
  on:click={() => dispatch("stop")}
105
  >
106
  <CarbonStopFilledAlt />
107
  </button>
108
  <div
109
+ class="mx-1 my-1 hidden h-[2.4rem] items-center p-1 px-[0.7rem] text-gray-400 enabled:hover:text-gray-700 disabled:opacity-60 enabled:dark:hover:text-gray-100 dark:disabled:opacity-40 md:flex"
110
  >
111
  <EosIconsLoading />
112
  </div>
113
  {:else}
114
  <button
115
+ class="btn mx-1 my-1 h-[2.4rem] self-end rounded-lg bg-transparent p-1 px-[0.7rem] text-gray-400 enabled:hover:text-gray-700 disabled:opacity-60 enabled:dark:hover:text-gray-100 dark:disabled:opacity-40"
116
  disabled={!message || isReadOnly}
117
  type="submit"
118
  >
 
128
  target="_blank"
129
  rel="noreferrer"
130
  class="hover:underline">{currentModel.displayName}</a
131
+ > <span class="max-sm:hidden">·</span><br class="sm:hidden" /> Generated content may be
132
+ inaccurate or false.
133
+ <br /><br /> 🔒 All conversations are end-to-end protected
134
  </p>
135
  <!-- {#if messages.length}
136
  <button
src/lib/server/database.ts CHANGED
@@ -1,15 +1,15 @@
1
- let client = undefined
2
- export const connectPromise = undefined
3
 
4
- const db = undefined
5
 
6
- const conversations = undefined
7
- const sharedConversations = undefined
8
- const abortedGenerations = undefined
9
- const settings = undefined
10
- const users = undefined
11
- const webSearches = undefined
12
- const messageEvents = undefined
13
 
14
  export { client, db };
15
  export const collections = {
@@ -20,4 +20,4 @@ export const collections = {
20
  users,
21
  webSearches,
22
  messageEvents,
23
- };
 
1
+ let client = undefined;
2
+ export const connectPromise = undefined;
3
 
4
+ const db = undefined;
5
 
6
+ const conversations = undefined;
7
+ const sharedConversations = undefined;
8
+ const abortedGenerations = undefined;
9
+ const settings = undefined;
10
+ const users = undefined;
11
+ const webSearches = undefined;
12
+ const messageEvents = undefined;
13
 
14
  export { client, db };
15
  export const collections = {
 
20
  users,
21
  webSearches,
22
  messageEvents,
23
+ };
src/lib/server/models.ts CHANGED
@@ -64,6 +64,8 @@ const modelsRaw = z
64
  displayName: z.string().min(1).optional(),
65
  description: z.string().min(1).optional(),
66
  is_local: z.boolean().optional(),
 
 
67
  websiteUrl: z.string().url().optional(),
68
  modelUrl: z.string().url().optional(),
69
  datasetName: z.string().min(1).optional(),
 
64
  displayName: z.string().min(1).optional(),
65
  description: z.string().min(1).optional(),
66
  is_local: z.boolean().optional(),
67
+ is_code: z.boolean().optional(),
68
+ type: z.string().min(1),
69
  websiteUrl: z.string().url().optional(),
70
  modelUrl: z.string().url().optional(),
71
  datasetName: z.string().min(1).optional(),
src/lib/types/Message.ts CHANGED
@@ -6,4 +6,5 @@ export type Message = Partial<Timestamps> & {
6
  content: string;
7
  webSearchId?: string;
8
  score?: -1 | 0 | 1;
 
9
  };
 
6
  content: string;
7
  webSearchId?: string;
8
  score?: -1 | 0 | 1;
9
+ isCode: boolean;
10
  };
src/routes/+layout.server.ts CHANGED
@@ -28,12 +28,10 @@ export const load: LayoutServerLoad = async ({ locals, depends, url }) => {
28
  throw redirect(302, url.pathname);
29
  }
30
 
31
-
32
  return {
33
  conversations: [],
34
  settings: {
35
- shareConversationsWithModelAuthors:
36
- DEFAULT_SETTINGS.shareConversationsWithModelAuthors,
37
  ethicsModalAcceptedAt: null,
38
  activeModel: DEFAULT_SETTINGS.activeModel,
39
  searchEnabled: false,
@@ -45,6 +43,8 @@ export const load: LayoutServerLoad = async ({ locals, depends, url }) => {
45
  websiteUrl: model.websiteUrl,
46
  modelUrl: model.modelUrl,
47
  is_local: model.is_local,
 
 
48
  datasetName: model.datasetName,
49
  datasetUrl: model.datasetUrl,
50
  displayName: model.displayName,
 
28
  throw redirect(302, url.pathname);
29
  }
30
 
 
31
  return {
32
  conversations: [],
33
  settings: {
34
+ shareConversationsWithModelAuthors: DEFAULT_SETTINGS.shareConversationsWithModelAuthors,
 
35
  ethicsModalAcceptedAt: null,
36
  activeModel: DEFAULT_SETTINGS.activeModel,
37
  searchEnabled: false,
 
43
  websiteUrl: model.websiteUrl,
44
  modelUrl: model.modelUrl,
45
  is_local: model.is_local,
46
+ is_code: model.is_code,
47
+ type: model.type,
48
  datasetName: model.datasetName,
49
  datasetUrl: model.datasetUrl,
50
  displayName: model.displayName,
src/routes/+layout.svelte CHANGED
@@ -19,8 +19,18 @@
19
  import LoadingModal from "$lib/components/LoadingModal.svelte";
20
  import LoginModal from "$lib/components/LoginModal.svelte";
21
  import { PUBLIC_APP_ASSETS, PUBLIC_APP_NAME } from "$env/static/public";
22
- import { isloading_writable, refresh_chats_writable, refresh_chats_writable_empty } from "./LayoutWritable";
23
- import { deleteAllChats, deleteChat, getChats, getMessages, modifyTitle } from "../routes/LocalDB";
 
 
 
 
 
 
 
 
 
 
24
  import { env } from "$env/dynamic/public";
25
 
26
  export let data;
@@ -29,7 +39,7 @@
29
 
30
  let go_to_main = false;
31
 
32
- let conversations_list = []
33
 
34
  isloading_writable.subscribe((value) => {
35
  isloading = value;
@@ -42,14 +52,14 @@
42
 
43
  refresh_chats_writable.subscribe(async (value) => {
44
  if (value.length > 0) {
45
- conversations_list = value
46
- refresh_chats_writable.set([])
47
  }
48
  });
49
 
50
  refresh_chats_writable_empty.subscribe(async (value) => {
51
- conversations_list = []
52
- refresh_chats_writable.set(conversations_list)
53
  });
54
 
55
  export function getProgress(progress: number) {}
@@ -74,19 +84,19 @@
74
  await deleteChat(id);
75
 
76
  if ($page.params.id !== id) {
77
- await invalidate(UrlDependency.ConversationList);
78
- } else {
79
- await goto(`${base}/`, { invalidateAll: true });
80
  }
81
  }
82
 
83
  async function deleteAllConversations(id: string) {
84
  await deleteAllChats();
85
-
86
  if ($page.params.id !== id) {
87
- await invalidate(UrlDependency.ConversationList);
88
- } else {
89
- await goto(`${base}/`, { invalidateAll: true });
90
  }
91
  }
92
 
@@ -95,7 +105,7 @@
95
  }
96
 
97
  onMount(async () => {
98
- await refreshChats()
99
  });
100
 
101
  onDestroy(() => {
@@ -105,7 +115,7 @@
105
  $: if ($error) onError();
106
 
107
  const requiresLogin =
108
- !$page.error &&
109
  !$page.route.id?.startsWith("/r/") &&
110
  (data.requiresLogin
111
  ? !data.user
@@ -114,12 +124,11 @@
114
  let loginModalVisible = false;
115
 
116
  async function refreshChats() {
117
- let ret = await getChats()
118
- data.conversations = ret
119
- conversations_list = ret
120
  }
121
  $: title = env.PUBLIC_APP_NAME;
122
-
123
  </script>
124
 
125
  <svelte:head>
@@ -194,9 +203,7 @@
194
  <Toast message={currentError} />
195
  {/if}
196
  {#if showWarning}
197
- <ConfirmModal
198
- on:close={() => (showWarning = false)}
199
- />
200
  {/if}
201
  {#if isloading}
202
  <LoadingModal />
@@ -204,6 +211,7 @@
204
  {#if isSettingsOpen}
205
  <SettingsModal
206
  on:close={() => (isSettingsOpen = false)}
 
207
  settings={data.settings}
208
  models={data.models}
209
  />
 
19
  import LoadingModal from "$lib/components/LoadingModal.svelte";
20
  import LoginModal from "$lib/components/LoginModal.svelte";
21
  import { PUBLIC_APP_ASSETS, PUBLIC_APP_NAME } from "$env/static/public";
22
+ import {
23
+ isloading_writable,
24
+ refresh_chats_writable,
25
+ refresh_chats_writable_empty,
26
+ } from "./LayoutWritable";
27
+ import {
28
+ deleteAllChats,
29
+ deleteChat,
30
+ getChats,
31
+ getMessages,
32
+ modifyTitle,
33
+ } from "../routes/LocalDB";
34
  import { env } from "$env/dynamic/public";
35
 
36
  export let data;
 
39
 
40
  let go_to_main = false;
41
 
42
+ let conversations_list = [];
43
 
44
  isloading_writable.subscribe((value) => {
45
  isloading = value;
 
52
 
53
  refresh_chats_writable.subscribe(async (value) => {
54
  if (value.length > 0) {
55
+ conversations_list = value;
56
+ refresh_chats_writable.set([]);
57
  }
58
  });
59
 
60
  refresh_chats_writable_empty.subscribe(async (value) => {
61
+ conversations_list = [];
62
+ refresh_chats_writable.set(conversations_list);
63
  });
64
 
65
  export function getProgress(progress: number) {}
 
84
  await deleteChat(id);
85
 
86
  if ($page.params.id !== id) {
87
+ await invalidate(UrlDependency.ConversationList);
88
+ } else {
89
+ await goto(`${base}/`, { invalidateAll: true });
90
  }
91
  }
92
 
93
  async function deleteAllConversations(id: string) {
94
  await deleteAllChats();
95
+
96
  if ($page.params.id !== id) {
97
+ await invalidate(UrlDependency.ConversationList);
98
+ } else {
99
+ await goto(`${base}/`, { invalidateAll: true });
100
  }
101
  }
102
 
 
105
  }
106
 
107
  onMount(async () => {
108
+ await refreshChats();
109
  });
110
 
111
  onDestroy(() => {
 
115
  $: if ($error) onError();
116
 
117
  const requiresLogin =
118
+ !$page.error &&
119
  !$page.route.id?.startsWith("/r/") &&
120
  (data.requiresLogin
121
  ? !data.user
 
124
  let loginModalVisible = false;
125
 
126
  async function refreshChats() {
127
+ let ret = await getChats();
128
+ data.conversations = ret;
129
+ conversations_list = ret;
130
  }
131
  $: title = env.PUBLIC_APP_NAME;
 
132
  </script>
133
 
134
  <svelte:head>
 
203
  <Toast message={currentError} />
204
  {/if}
205
  {#if showWarning}
206
+ <ConfirmModal on:close={() => (showWarning = false)} />
 
 
207
  {/if}
208
  {#if isloading}
209
  <LoadingModal />
 
211
  {#if isSettingsOpen}
212
  <SettingsModal
213
  on:close={() => (isSettingsOpen = false)}
214
+ on:deleteAllConversations={() => ((isSettingsOpen = false), deleteAllChats())}
215
  settings={data.settings}
216
  models={data.models}
217
  />
src/routes/+page.svelte CHANGED
@@ -8,21 +8,28 @@
8
  import { findCurrentModel } from "$lib/utils/models";
9
  import { createChat } from "../routes/LocalDB";
10
  import { params_writable } from "../routes/conversation/[id]/ParamsWritable";
 
 
 
 
 
 
 
11
 
12
  export let data;
13
  let loading = false;
14
 
15
  // dec2hex :: Integer -> String
16
  // i.e. 0-255 -> '00'-'ff'
17
- function dec2hex (dec) {
18
- return dec.toString(16).padStart(2, "0")
19
  }
20
 
21
  // generateId :: Integer -> String
22
- function generateId (len) {
23
- var arr = new Uint8Array((len || 40) / 2)
24
- window.crypto.getRandomValues(arr)
25
- return Array.from(arr, dec2hex).join('')
26
  }
27
 
28
  async function createConversation(message: string) {
@@ -34,8 +41,8 @@
34
  // Ugly hack to use a store as temp storage, feel free to improve ^^
35
  pendingMessage.set(message);
36
 
37
- console.log(conversationId)
38
- params_writable.set(conversationId)
39
  // invalidateAll to update list of conversations
40
  await goto(`${base}/conversation/${conversationId}`, { invalidateAll: true });
41
  } catch (err) {
@@ -48,13 +55,16 @@
48
  </script>
49
 
50
  <svelte:head>
51
- <title>{PUBLIC_APP_NAME}</title>
52
  </svelte:head>
53
 
54
  <ChatWindow
55
  on:message={(ev) => createConversation(ev.detail)}
56
  {loading}
57
- currentModel={findCurrentModel([...data.models, ...data.oldModels], data.settings.activeModel)}
 
 
 
58
  models={data.models}
59
  settings={data.settings}
60
  />
 
8
  import { findCurrentModel } from "$lib/utils/models";
9
  import { createChat } from "../routes/LocalDB";
10
  import { params_writable } from "../routes/conversation/[id]/ParamsWritable";
11
+ import { curr_model_writable, curr_model_writable_string } from "./LayoutWritable";
12
+
13
+ let curr_model_id = 0;
14
+
15
+ curr_model_writable.subscribe((val) => {
16
+ curr_model_id = val;
17
+ });
18
 
19
  export let data;
20
  let loading = false;
21
 
22
  // dec2hex :: Integer -> String
23
  // i.e. 0-255 -> '00'-'ff'
24
+ function dec2hex(dec) {
25
+ return dec.toString(16).padStart(2, "0");
26
  }
27
 
28
  // generateId :: Integer -> String
29
+ function generateId(len) {
30
+ var arr = new Uint8Array((len || 40) / 2);
31
+ window.crypto.getRandomValues(arr);
32
+ return Array.from(arr, dec2hex).join("");
33
  }
34
 
35
  async function createConversation(message: string) {
 
41
  // Ugly hack to use a store as temp storage, feel free to improve ^^
42
  pendingMessage.set(message);
43
 
44
+ console.log(conversationId);
45
+ params_writable.set(conversationId);
46
  // invalidateAll to update list of conversations
47
  await goto(`${base}/conversation/${conversationId}`, { invalidateAll: true });
48
  } catch (err) {
 
55
  </script>
56
 
57
  <svelte:head>
58
+ <title>{PUBLIC_APP_NAME}</title>
59
  </svelte:head>
60
 
61
  <ChatWindow
62
  on:message={(ev) => createConversation(ev.detail)}
63
  {loading}
64
+ currentModel={findCurrentModel(
65
+ [...data.models, ...data.oldModels],
66
+ data.models[curr_model_id].name
67
+ )}
68
  models={data.models}
69
  settings={data.settings}
70
  />
src/routes/LayoutWritable.js CHANGED
@@ -3,3 +3,5 @@ import { writable } from "svelte/store";
3
  export const isloading_writable = writable(false);
4
  export const refresh_chats_writable = writable([]);
5
  export const refresh_chats_writable_empty = writable(false);
 
 
 
3
  export const isloading_writable = writable(false);
4
  export const refresh_chats_writable = writable([]);
5
  export const refresh_chats_writable_empty = writable(false);
6
+ export const curr_model_writable = writable(0);
7
+ export const curr_model_writable_string = writable("");
src/routes/LocalDB.ts CHANGED
@@ -1,154 +1,170 @@
1
- import Dexie, { type Table, liveQuery } from 'dexie';
2
  import { refresh_chats_writable_empty, refresh_chats_writable } from "../routes/LayoutWritable";
3
- import { env } from '$env/dynamic/public';
4
 
5
  export interface Chat {
6
- index?: number;
7
- title: string,
8
- id: string;
9
- createdAt: Date,
10
- message?: Array<MessageDb>;
 
11
  }
12
 
13
  export interface MessageDb {
14
- content: string;
15
- from: string;
16
- id: string;
17
- createdAt: Date;
18
- updatedAt: Date;
19
  }
20
 
21
  export class ChatDatabase extends Dexie {
22
- chats!: Table<Chat>;
23
-
24
- constructor() {
25
- super('blindchat');
26
- this.version(16).stores({
27
- chats: '++index, title, createdAt, id, message'
28
- });
29
- }
 
 
 
30
  }
31
 
32
- export async function createChat(id_chat: string, msg: MessageDb | undefined, title?: string) {
33
- try {
34
- let title_f = ""
35
- if (title === undefined) {
36
- let count = (await db.chats.count()) + 1
37
- title_f = "Untitled " + count
38
- }
39
- else
40
- title_f = title
41
- const chat = {
42
- id: id_chat,
43
- title: title_f,
44
- message: msg === undefined ? undefined : [msg],
45
- createdAt: new Date(),
46
- }
47
- const id = await db.chats.add(chat);
48
- } catch (error) {
49
- console.log(error)
50
- }
51
- let push = await getChats()
52
- refresh_chats_writable.set(push)
 
 
 
 
53
  }
54
 
55
  export async function deleteAllChats() {
56
- const chat_ret = await db.chats.clear()
57
- refresh_chats_writable_empty.set(true)
58
  }
59
 
60
  export async function deleteChat(id_chat: string) {
61
- const chat_ret = await db.chats.where("id").equals(id_chat).delete()
62
- let count = await db.chats.count()
63
- if (count > 0) {
64
- let push = await getChats()
65
- refresh_chats_writable.set(push)
66
- }
67
- else {
68
- refresh_chats_writable_empty.set(true)
69
- }
70
  }
71
 
72
  export async function modifyTitle(id_chat: string, newTitle: string) {
73
- const chat_ret = db.chats.where("id").equals(id_chat)
74
- let count = await chat_ret.count()
75
- if (count > 0) {
76
- let res = await chat_ret.first()
77
- chat_ret.modify({title: newTitle})
78
- let push = await getChats()
79
- refresh_chats_writable.set(push)
80
- }
81
  }
82
 
83
- export async function addMessageToChat(id_chat: string, msg: MessageDb) {
84
- const chat_ret = db.chats.where("id").equals(id_chat)
85
- let count = await chat_ret.count()
86
- if (count < 1) {
87
- createChat(id_chat, msg, )
88
- }
89
- else {
90
- let msgs: MessageDb[]
91
- chat_ret.first().then((res) => {
92
- if (res?.message == undefined) {
93
- msgs.push(msg)
94
- res.message = msgs
95
- }
96
- res.message.push(msg)
97
- chat_ret.modify({id: id_chat, message: res.message})
98
- })
99
- }
100
  }
101
 
102
  export async function getTitle(id_chat: string) {
103
- let title_ret = env.PUBLIC_APP_NAME
104
- try {
105
- const chat_ret = await (db.chats.where("id").equals(id_chat).first())
106
- title_ret = chat_ret!.title
107
- }
108
- catch (err) {
109
- console.log(err)
110
- }
111
- return title_ret
112
  }
113
 
114
  export async function getMessages(id_chat: string) {
115
- try {
116
- const chat_ret = await db.chats.where("id").equals(id_chat).first()
117
- const msg = chat_ret?.message
118
- return [...msg]
119
- }
120
- catch (err) {
121
- console.log(err)
122
- }
123
- return undefined
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
 
126
  export async function getChats() {
127
- let titles = []
128
- try {
129
- const all = (await db.chats.orderBy('createdAt').toArray()).forEach(function (chat) {
130
- titles.push({
131
- title: chat.title,
132
  model: "", // Hardcoded for now
133
  id: chat.id,
134
  updatedAt: chat.createdAt,
135
  createdAt: chat.createdAt,
136
- })
137
- });
138
- }
139
- catch (err) {
140
- console.log(err)
141
- }
142
- return titles;
143
  }
144
 
145
-
146
  export async function getChat(id_chat: string) {
147
- const chat_ret = db.chats.where("id").equals(id_chat).first().then((res) => {
148
- return res;
149
- })
 
 
 
 
150
  }
151
 
152
  export const db = new ChatDatabase();
153
-
154
-
 
1
+ import Dexie, { type Table, liveQuery } from "dexie";
2
  import { refresh_chats_writable_empty, refresh_chats_writable } from "../routes/LayoutWritable";
3
+ import { env } from "$env/dynamic/public";
4
 
5
  export interface Chat {
6
+ index?: number;
7
+ title: string;
8
+ id: string;
9
+ createdAt: Date;
10
+ model: string;
11
+ message?: Array<MessageDb>;
12
  }
13
 
14
  export interface MessageDb {
15
+ content: string;
16
+ from: string;
17
+ id: string;
18
+ createdAt: Date;
19
+ updatedAt: Date;
20
  }
21
 
22
  export class ChatDatabase extends Dexie {
23
+ chats!: Table<Chat>;
24
+
25
+ constructor() {
26
+ super("blindchat");
27
+ this.version(16).stores({
28
+ chats: null,
29
+ });
30
+ this.version(17).stores({
31
+ chats: "++index, title, createdAt, id, message, model",
32
+ });
33
+ }
34
  }
35
 
36
+ export async function createChat(
37
+ id_chat: string,
38
+ msg: MessageDb | undefined,
39
+ model: string,
40
+ title?: string
41
+ ) {
42
+ try {
43
+ let title_f = "";
44
+ if (title === undefined) {
45
+ let count = (await db.chats.count()) + 1;
46
+ title_f = "Untitled " + count;
47
+ } else title_f = title;
48
+ const chat = {
49
+ id: id_chat,
50
+ title: title_f,
51
+ message: msg === undefined ? undefined : [msg],
52
+ createdAt: new Date(),
53
+ model: model,
54
+ };
55
+ const id = await db.chats.add(chat);
56
+ } catch (error) {
57
+ console.log(error);
58
+ }
59
+ let push = await getChats();
60
+ refresh_chats_writable.set(push);
61
  }
62
 
63
  export async function deleteAllChats() {
64
+ const chat_ret = await db.chats.clear();
65
+ refresh_chats_writable_empty.set(true);
66
  }
67
 
68
  export async function deleteChat(id_chat: string) {
69
+ const chat_ret = await db.chats.where("id").equals(id_chat).delete();
70
+ let count = await db.chats.count();
71
+ if (count > 0) {
72
+ let push = await getChats();
73
+ refresh_chats_writable.set(push);
74
+ } else {
75
+ refresh_chats_writable_empty.set(true);
76
+ }
 
77
  }
78
 
79
  export async function modifyTitle(id_chat: string, newTitle: string) {
80
+ const chat_ret = db.chats.where("id").equals(id_chat);
81
+ let count = await chat_ret.count();
82
+ if (count > 0) {
83
+ let res = await chat_ret.first();
84
+ chat_ret.modify({ title: newTitle });
85
+ let push = await getChats();
86
+ refresh_chats_writable.set(push);
87
+ }
88
  }
89
 
90
+ export async function addMessageToChat(id_chat: string, msg: MessageDb, model: string) {
91
+ const chat_ret = db.chats.where("id").equals(id_chat);
92
+ let count = await chat_ret.count();
93
+ if (count < 1) {
94
+ createChat(id_chat, msg, model);
95
+ } else {
96
+ let msgs: MessageDb[];
97
+ chat_ret.first().then((res) => {
98
+ if (res?.message == undefined) {
99
+ msgs.push(msg);
100
+ res.message = msgs;
101
+ }
102
+ res.message.push(msg);
103
+ chat_ret.modify({ id: id_chat, message: res.message });
104
+ });
105
+ }
 
106
  }
107
 
108
  export async function getTitle(id_chat: string) {
109
+ let title_ret = env.PUBLIC_APP_NAME;
110
+ try {
111
+ const chat_ret = await db.chats.where("id").equals(id_chat).first();
112
+ title_ret = chat_ret!.title;
113
+ } catch (err) {
114
+ console.log(err);
115
+ }
116
+ return title_ret;
 
117
  }
118
 
119
  export async function getMessages(id_chat: string) {
120
+ try {
121
+ const chat_ret = await db.chats.where("id").equals(id_chat).first();
122
+ const msg = chat_ret?.message;
123
+ return [...msg];
124
+ } catch (err) {
125
+ console.log(err);
126
+ }
127
+ return undefined;
128
+ }
129
+
130
+ export async function getModel(id_chat: string) {
131
+ try {
132
+ const chat_ret = await db.chats.where("id").equals(id_chat).first();
133
+ let model = chat_ret?.model;
134
+ if (model === undefined) return "";
135
+ return model;
136
+ } catch (err) {
137
+ console.log(err);
138
+ }
139
+ return "";
140
  }
141
 
142
  export async function getChats() {
143
+ let titles = [];
144
+ try {
145
+ const all = (await db.chats.orderBy("createdAt").toArray()).forEach(function (chat) {
146
+ titles.push({
147
+ title: chat.title,
148
  model: "", // Hardcoded for now
149
  id: chat.id,
150
  updatedAt: chat.createdAt,
151
  createdAt: chat.createdAt,
152
+ });
153
+ });
154
+ } catch (err) {
155
+ console.log(err);
156
+ }
157
+ return titles;
 
158
  }
159
 
 
160
  export async function getChat(id_chat: string) {
161
+ const chat_ret = db.chats
162
+ .where("id")
163
+ .equals(id_chat)
164
+ .first()
165
+ .then((res) => {
166
+ return res;
167
+ });
168
  }
169
 
170
  export const db = new ChatDatabase();
 
 
src/routes/conversation/[id]/+page.svelte CHANGED
@@ -16,27 +16,36 @@
16
  import type { Message } from "$lib/types/Message";
17
  import { PUBLIC_APP_DISCLAIMER } from "$env/static/public";
18
  import { pipeline, Pipeline, env as env_transformers } from "@xenova/transformers";
19
- import { isloading_writable } from "../../LayoutWritable.js";
20
  import { map_writable } from "$lib/components/LoadingModalWritable.js";
21
  import { params_writable } from "./ParamsWritable.js";
22
- import { addMessageToChat,getChats,getMessages,getTitle } from "../../LocalDB.js";
23
  import { env } from "$env/dynamic/public";
24
  export let data;
25
 
 
 
 
 
 
 
26
  let pipelineWorker;
27
 
28
  let pipe: Pipeline;
29
 
30
- let id = ""
 
 
 
 
 
31
 
32
- let title_ret = "BlindChat"
33
 
34
  let messages = [];
35
  let lastLoadedMessages = [];
36
  let isAborted = false;
37
 
38
- console.log(" - " + $page.params.id)
39
-
40
  let webSearchMessages: WebSearchMessage[] = [];
41
 
42
  // // Since we modify the messages array locally, we don't want to reset it if an old version is passed
@@ -69,30 +78,32 @@
69
  break;
70
 
71
  case "update":
72
- if (lastMessage == undefined) lastMessage = messages[messages.length - 1];
73
- lastMessage.content = e.data.output;
74
- lastMessage.webSearchId = e.data.searchID;
75
- lastMessage.updatedAt = new Date()
76
- messages = [...messages];
 
 
77
  break;
78
 
79
  case "complete":
80
- lastMessage = messages[messages.length - 1];
81
- lastMessage.webSearchId = e.data.searchID;
82
- lastMessage.updatedAt = new Date()
83
- addMessageToChat($page.params.id, lastMessage)
84
- messages = [...messages];
85
- lastMessage = undefined;
86
- loading = false;
87
- pending = false;
88
- webSearchMessages = [];
89
-
90
- if (messages.filter((m) => m.from === "user").length === 1) {
91
- invalidate(UrlDependency.ConversationList).catch(console.error);
92
- } else {
93
- invalidate(UrlDependency.ConversationList).then((value) => {
94
- console.log(value);
95
- });
96
  }
97
  break;
98
  }
@@ -109,27 +120,43 @@
109
 
110
  let opt = "";
111
 
 
 
112
  messages = [
113
  ...messages,
114
  // id doesn't match the backend id but it's not important for assistant messages
115
- { from: "assistant", content: "", id: responseId, createdAt: new Date(), updatedAt: new Date() },
116
- ];
117
-
118
- let msg =
119
- {
120
- content: inputs,
121
- from: "user",
122
- id: randomUUID(),
123
  createdAt: new Date(),
124
  updatedAt: new Date(),
125
- };
 
 
126
 
127
- console.log(findCurrentModel([...data.models, ...data.oldModels], data.settings.activeModel))
 
 
 
 
 
 
 
128
 
129
- addMessageToChat(conversationId, msg)
130
 
131
  let lastMessage = messages[messages.length - 1];
132
- pipelineWorker.postMessage({ text: inputs, webSearchId: webSearchId, conversationId: conversationId });
 
 
 
 
 
 
 
 
 
133
  }
134
 
135
  async function summarizeTitle(id: string) {
@@ -256,30 +283,59 @@
256
  }
257
 
258
  params_writable.subscribe(async (value) => {
259
- if (value != id) {
260
- id = value
261
- //title_ret = await getTitle(value)
262
- let res = await getMessages(value)
263
-
264
- if (res != undefined) {
265
- messages = res
266
- lastLoadedMessages = res
267
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
 
 
 
269
  });
270
 
271
  onMount(async () => {
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  const Worker = await import("./worker.js?worker");
273
  pipelineWorker = new Worker.default();
274
-
275
  //title_ret = await getTitle($page.params.id)
276
- let res = await getMessages($page.params.id)
 
 
277
 
278
- id = $page.params.id
279
-
280
  if (res != undefined) {
281
- messages = res
282
- lastLoadedMessages = res
283
  }
284
 
285
  pipelineWorker.addEventListener("message", onMessageReceived);
@@ -319,7 +375,7 @@
319
  on:share={() => shareConversation($page.params.id, data.title)}
320
  on:stop={() => (isAborted = true)}
321
  models={data.models}
322
- currentModel={findCurrentModel([...data.models, ...data.oldModels], data.model)}
323
  settings={data.settings}
324
  {loginRequired}
325
  />
 
16
  import type { Message } from "$lib/types/Message";
17
  import { PUBLIC_APP_DISCLAIMER } from "$env/static/public";
18
  import { pipeline, Pipeline, env as env_transformers } from "@xenova/transformers";
19
+ import { isloading_writable, curr_model_writable } from "../../LayoutWritable.js";
20
  import { map_writable } from "$lib/components/LoadingModalWritable.js";
21
  import { params_writable } from "./ParamsWritable.js";
22
+ import { addMessageToChat, getChats, getMessages, getTitle, getModel } from "../../LocalDB.js";
23
  import { env } from "$env/dynamic/public";
24
  export let data;
25
 
26
+ let curr_model_id = 0;
27
+ curr_model_writable.subscribe((val) => {
28
+ curr_model_id = val;
29
+ console.log(val);
30
+ });
31
+
32
  let pipelineWorker;
33
 
34
  let pipe: Pipeline;
35
 
36
+ let id = "";
37
+
38
+ let title_ret = "BlindChat";
39
+
40
+ let curr_model = data.model;
41
+ let curr_model_obj;
42
 
43
+ let id_now;
44
 
45
  let messages = [];
46
  let lastLoadedMessages = [];
47
  let isAborted = false;
48
 
 
 
49
  let webSearchMessages: WebSearchMessage[] = [];
50
 
51
  // // Since we modify the messages array locally, we don't want to reset it if an old version is passed
 
78
  break;
79
 
80
  case "update":
81
+ if (e.data.id_now == id_now) {
82
+ if (lastMessage == undefined) lastMessage = messages[messages.length - 1];
83
+ lastMessage.content = e.data.output;
84
+ lastMessage.webSearchId = e.data.searchID;
85
+ lastMessage.updatedAt = new Date();
86
+ messages = [...messages];
87
+ }
88
  break;
89
 
90
  case "complete":
91
+ if (e.data.id_now == id_now) {
92
+ lastMessage = messages[messages.length - 1];
93
+ lastMessage.webSearchId = e.data.searchID;
94
+ lastMessage.updatedAt = new Date();
95
+ addMessageToChat($page.params.id, lastMessage);
96
+ messages = [...messages];
97
+ lastMessage = undefined;
98
+ loading = false;
99
+ pending = false;
100
+ webSearchMessages = [];
101
+
102
+ if (messages.filter((m) => m.from === "user").length === 1) {
103
+ invalidate(UrlDependency.ConversationList).catch(console.error);
104
+ } else {
105
+ invalidate(UrlDependency.ConversationList).then((value) => {});
106
+ }
107
  }
108
  break;
109
  }
 
120
 
121
  let opt = "";
122
 
123
+ console.log(curr_model_obj);
124
+
125
  messages = [
126
  ...messages,
127
  // id doesn't match the backend id but it's not important for assistant messages
128
+ {
129
+ from: "assistant",
130
+ content: "",
131
+ id: responseId,
 
 
 
 
132
  createdAt: new Date(),
133
  updatedAt: new Date(),
134
+ isCode: curr_model_obj.is_code ?? false,
135
+ },
136
+ ];
137
 
138
+ let msg = {
139
+ content: inputs,
140
+ from: "user",
141
+ id: randomUUID(),
142
+ createdAt: new Date(),
143
+ updatedAt: new Date(),
144
+ isCode: false,
145
+ };
146
 
147
+ addMessageToChat(conversationId, msg, curr_model);
148
 
149
  let lastMessage = messages[messages.length - 1];
150
+ pipelineWorker.postMessage({
151
+ id_now: id_now,
152
+ task: curr_model_obj.type,
153
+ max_new_tokens: curr_model_obj.parameters?.max_new_tokens ?? 256,
154
+ temperature: curr_model_obj.parameters?.temperature ?? 0.7,
155
+ model: curr_model,
156
+ text: inputs,
157
+ webSearchId: webSearchId,
158
+ conversationId: conversationId,
159
+ });
160
  }
161
 
162
  async function summarizeTitle(id: string) {
 
283
  }
284
 
285
  params_writable.subscribe(async (value) => {
286
+ if (value != id) {
287
+ id = value;
288
+ //title_ret = await getTitle(value)
289
+ let res = await getMessages(value);
290
+
291
+ curr_model = await getModel(value);
292
+ if (curr_model === undefined || curr_model.length == 0) {
293
+ curr_model_obj = findCurrentModel(
294
+ [...data.models, ...data.oldModels],
295
+ data.models[curr_model_id].name
296
+ );
297
+ curr_model = curr_model_obj.name;
298
+ } else {
299
+ curr_model_obj = findCurrentModel([...data.models, ...data.oldModels], curr_model);
300
+ }
301
+
302
+ console.log(curr_model);
303
+ console.log(curr_model_obj);
304
+
305
+ if (res != undefined) {
306
+ messages = res;
307
+ lastLoadedMessages = res;
308
  }
309
+
310
+ id_now = randomUUID();
311
+ }
312
  });
313
 
314
  onMount(async () => {
315
+ curr_model = await getModel($page.params.id);
316
+ if (curr_model === undefined || curr_model.length == 0) {
317
+ curr_model_obj = findCurrentModel(
318
+ [...data.models, ...data.oldModels],
319
+ data.models[curr_model_id].name
320
+ );
321
+ curr_model = curr_model_obj.name;
322
+ } else {
323
+ curr_model_obj = findCurrentModel([...data.models, ...data.oldModels], curr_model);
324
+ }
325
+
326
+ id_now = randomUUID();
327
+
328
  const Worker = await import("./worker.js?worker");
329
  pipelineWorker = new Worker.default();
330
+
331
  //title_ret = await getTitle($page.params.id)
332
+ let res = await getMessages($page.params.id);
333
+
334
+ id = $page.params.id;
335
 
 
 
336
  if (res != undefined) {
337
+ messages = res;
338
+ lastLoadedMessages = res;
339
  }
340
 
341
  pipelineWorker.addEventListener("message", onMessageReceived);
 
375
  on:share={() => shareConversation($page.params.id, data.title)}
376
  on:stop={() => (isAborted = true)}
377
  models={data.models}
378
+ currentModel={findCurrentModel([...data.models, ...data.oldModels], curr_model)}
379
  settings={data.settings}
380
  {loginRequired}
381
  />
src/routes/conversation/[id]/ParamsWritable.js CHANGED
@@ -1,3 +1,3 @@
1
  import { writable } from "svelte/store";
2
 
3
- export const params_writable = writable("");
 
1
  import { writable } from "svelte/store";
2
 
3
+ export const params_writable = writable("");
src/routes/conversation/[id]/summarize/+server.ts CHANGED
@@ -52,8 +52,5 @@ export async function POST({ params, locals }) {
52
  { headers: { "Content-Type": "application/json" } }
53
  );*/
54
 
55
- return new Response(
56
- JSON.stringify({}),
57
- { headers: { "Content-Type": "application/json" } }
58
- );
59
  }
 
52
  { headers: { "Content-Type": "application/json" } }
53
  );*/
54
 
55
+ return new Response(JSON.stringify({}), { headers: { "Content-Type": "application/json" } });
 
 
 
56
  }
src/routes/conversation/[id]/worker.js CHANGED
@@ -1,13 +1,18 @@
1
  import { pipeline, env } from "@xenova/transformers";
2
 
3
  export class FlanPipeline {
4
- static task = "text2text-generation";
5
- static model = "Xenova/LaMini-Flan-T5-783M";
6
  static instance = null;
7
 
8
- static async getInstance(progress_callback = null) {
9
  if (this.instance === null) {
10
- this.instance = pipeline(this.task, this.model, { progress_callback });
 
 
 
 
 
 
11
  }
12
  return this.instance;
13
  }
@@ -15,16 +20,22 @@ export class FlanPipeline {
15
 
16
  // Listen for messages from the main thread
17
  self.addEventListener("message", async (event) => {
18
- let pipe = await FlanPipeline.getInstance((x) => {
19
- self.postMessage(x);
20
- });
 
 
 
 
21
 
22
  let output = await pipe(event.data.text, {
23
- max_new_tokens: 256,
 
24
  callback_function: (x) => {
25
  self.postMessage({
26
  status: "update",
27
  output: pipe.tokenizer.decode(x[0].output_token_ids, { skip_special_tokens: true }),
 
28
  });
29
  },
30
  });
@@ -34,5 +45,6 @@ self.addEventListener("message", async (event) => {
34
  status: "complete",
35
  output: output,
36
  searchID: event.data.searchID,
 
37
  });
38
  });
 
1
  import { pipeline, env } from "@xenova/transformers";
2
 
3
  export class FlanPipeline {
4
+ static curr_model = "";
 
5
  static instance = null;
6
 
7
+ static async getInstance(progress_callback = null, model, task) {
8
  if (this.instance === null) {
9
+ this.instance = pipeline(task, model, { progress_callback });
10
+ this.curr_model = model;
11
+ } else {
12
+ if (this.curr_model != model) {
13
+ this.instance = pipeline(task, model, { progress_callback });
14
+ this.curr_model = model;
15
+ }
16
  }
17
  return this.instance;
18
  }
 
20
 
21
  // Listen for messages from the main thread
22
  self.addEventListener("message", async (event) => {
23
+ let pipe = await FlanPipeline.getInstance(
24
+ (x) => {
25
+ self.postMessage(x);
26
+ },
27
+ event.data.model,
28
+ event.data.task
29
+ );
30
 
31
  let output = await pipe(event.data.text, {
32
+ max_new_tokens: event.data.max_new_tokens,
33
+ temperature: event.data.temperature,
34
  callback_function: (x) => {
35
  self.postMessage({
36
  status: "update",
37
  output: pipe.tokenizer.decode(x[0].output_token_ids, { skip_special_tokens: true }),
38
+ id_now: event.data.id_now,
39
  });
40
  },
41
  });
 
45
  status: "complete",
46
  output: output,
47
  searchID: event.data.searchID,
48
+ id_now: event.data.id_now,
49
  });
50
  });
src/routes/conversations/+page.server.ts CHANGED
@@ -7,4 +7,4 @@ export const actions = {
7
  delete: async function ({ locals }) {
8
  throw redirect(303, `${base}/`);
9
  },
10
- };
 
7
  delete: async function ({ locals }) {
8
  throw redirect(303, `${base}/`);
9
  },
10
+ };
src/routes/login/callback/updateUser.ts CHANGED
@@ -9,6 +9,4 @@ export async function updateUser(params: {
9
  userData: UserinfoResponse;
10
  locals: App.Locals;
11
  cookies: Cookies;
12
- }) {
13
-
14
- }
 
9
  userData: UserinfoResponse;
10
  locals: App.Locals;
11
  cookies: Cookies;
12
+ }) {}
 
 
src/routes/r/[id]/+page.svelte CHANGED
@@ -16,7 +16,6 @@
16
  let loading = false;
17
 
18
  async function createConversation() {
19
- console.log("create")
20
  try {
21
  loading = true;
22
  const res = await fetch(`${base}/conversation`, {
 
16
  let loading = false;
17
 
18
  async function createConversation() {
 
19
  try {
20
  loading = true;
21
  const res = await fetch(`${base}/conversation`, {
src/routes/settings/+page.server.ts CHANGED
@@ -28,22 +28,6 @@ export const actions = {
28
  customPrompts: JSON.parse(formData.get("customPrompts")?.toString() ?? "{}"),
29
  });
30
 
31
- await collections.settings.updateOne(
32
- authCondition(locals),
33
- {
34
- $set: {
35
- ...settings,
36
- ...(ethicsModalAccepted && { ethicsModalAcceptedAt: new Date() }),
37
- updatedAt: new Date(),
38
- },
39
- $setOnInsert: {
40
- createdAt: new Date(),
41
- },
42
- },
43
- {
44
- upsert: true,
45
- }
46
- );
47
  throw redirect(303, request.headers.get("referer") || `${base}/`);
48
  },
49
  };
 
28
  customPrompts: JSON.parse(formData.get("customPrompts")?.toString() ?? "{}"),
29
  });
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  throw redirect(303, request.headers.get("referer") || `${base}/`);
32
  },
33
  };