"docker/transformers-pytorch-tpu/dataset.yaml" did not exist on "6695450a23545bc9d5416f39ab39609c7811c653"
+page.svelte 17 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
<script lang="ts">
2
	import { v4 as uuidv4 } from 'uuid';
Timothy J. Baek's avatar
Timothy J. Baek committed
3
4
	import toast from 'svelte-french-toast';

Timothy J. Baek's avatar
Timothy J. Baek committed
5
	import { onMount, tick } from 'svelte';
6
	import { goto } from '$app/navigation';
7
	import { page } from '$app/stores';
Timothy J. Baek's avatar
Timothy J. Baek committed
8

Timothy J. Baek's avatar
Timothy J. Baek committed
9
	import { models, modelfiles, user, settings, db, chats, chatId } from '$lib/stores';
10
	import { OLLAMA_API_BASE_URL } from '$lib/constants';
Timothy J. Baek's avatar
Timothy J. Baek committed
11
12
13

	import { generateChatCompletion, generateTitle } from '$lib/apis/ollama';
	import { copyToClipboard, splitStream } from '$lib/utils';
14
15
16
17

	import MessageInput from '$lib/components/chat/MessageInput.svelte';
	import Messages from '$lib/components/chat/Messages.svelte';
	import ModelSelector from '$lib/components/chat/ModelSelector.svelte';
18
	import Navbar from '$lib/components/layout/Navbar.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
19
	import { createNewChat, getChatList, updateChatById } from '$lib/apis/chats';
20

21
22
	let stopResponseFlag = false;
	let autoScroll = true;
Timothy J. Baek's avatar
Timothy J. Baek committed
23

Timothy J. Baek's avatar
Timothy J. Baek committed
24
	let selectedModels = [''];
Timothy J. Baek's avatar
Timothy J. Baek committed
25

26
27
28
29
30
31
	let selectedModelfile = null;
	$: selectedModelfile =
		selectedModels.length === 1 &&
		$modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0]).length > 0
			? $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0])[0]
			: null;
32

33
34
	let chat = null;

Timothy J. Baek's avatar
Timothy J. Baek committed
35
	let title = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
36
	let prompt = '';
37
	let files = [];
38
	let messages = [];
Timothy J. Baek's avatar
Timothy J. Baek committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	let history = {
		messages: {},
		currentId: null
	};

	$: if (history.currentId !== null) {
		let _messages = [];

		let currentMessage = history.messages[history.currentId];
		while (currentMessage !== null) {
			_messages.unshift({ ...currentMessage });
			currentMessage =
				currentMessage.parentId !== null ? history.messages[currentMessage.parentId] : null;
		}
		messages = _messages;
Timothy J. Baek's avatar
Timothy J. Baek committed
54
55
	} else {
		messages = [];
Timothy J. Baek's avatar
Timothy J. Baek committed
56
	}
Timothy J. Baek's avatar
Timothy J. Baek committed
57

58
	onMount(async () => {
59
		await initNewChat();
60
61
62
63
64
65
	});

	//////////////////////////
	// Web functions
	//////////////////////////

66
	const initNewChat = async () => {
67
68
69
		console.log('initNewChat');

		await chatId.set('');
70
		console.log($chatId);
Timothy J. Baek's avatar
Timothy J. Baek committed
71

72
		autoScroll = true;
Timothy J. Baek's avatar
Timothy J. Baek committed
73

74
75
76
77
78
		title = '';
		messages = [];
		history = {
			messages: {},
			currentId: null
Timothy J. Baek's avatar
Timothy J. Baek committed
79
		};
80
81
82
		selectedModels = $page.url.searchParams.get('models')
			? $page.url.searchParams.get('models')?.split(',')
			: $settings.models ?? [''];
83
84
85
86
87

		let _settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
		settings.set({
			..._settings
		});
Timothy J. Baek's avatar
Timothy J. Baek committed
88
89
	};

90
91
92
93
	//////////////////////////
	// Ollama functions
	//////////////////////////

94
95
	const sendPrompt = async (prompt, parentId) => {
		const _chatId = JSON.parse(JSON.stringify($chatId));
Timothy J. Baek's avatar
Timothy J. Baek committed
96
97
		await Promise.all(
			selectedModels.map(async (model) => {
98
99
				console.log(model);
				if ($models.filter((m) => m.name === model)[0].external) {
100
					await sendPromptOpenAI(model, prompt, parentId, _chatId);
Timothy J. Baek's avatar
Timothy J. Baek committed
101
				} else {
102
					await sendPromptOllama(model, prompt, parentId, _chatId);
Timothy J. Baek's avatar
Timothy J. Baek committed
103
104
105
				}
			})
		);
106

Timothy J. Baek's avatar
Timothy J. Baek committed
107
		await chats.set(await getChatList(localStorage.token));
108
109
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
110
	const sendPromptOllama = async (model, userPrompt, parentId, _chatId) => {
Timothy J. Baek's avatar
Timothy J. Baek committed
111
		// Create response message
Timothy J. Baek's avatar
Timothy J. Baek committed
112
		let responseMessageId = uuidv4();
113
		let responseMessage = {
Timothy J. Baek's avatar
Timothy J. Baek committed
114
115
116
			parentId: parentId,
			id: responseMessageId,
			childrenIds: [],
117
			role: 'assistant',
Timothy J. Baek's avatar
Timothy J. Baek committed
118
119
			content: '',
			model: model
120
121
		};

Timothy J. Baek's avatar
Timothy J. Baek committed
122
		// Add message to history and Set currentId to messageId
Timothy J. Baek's avatar
Timothy J. Baek committed
123
124
		history.messages[responseMessageId] = responseMessage;
		history.currentId = responseMessageId;
Timothy J. Baek's avatar
Timothy J. Baek committed
125
126

		// Append messageId to childrenIds of parent message
Timothy J. Baek's avatar
Timothy J. Baek committed
127
128
129
130
131
132
133
		if (parentId !== null) {
			history.messages[parentId].childrenIds = [
				...history.messages[parentId].childrenIds,
				responseMessageId
			];
		}

Timothy J. Baek's avatar
Timothy J. Baek committed
134
		// Wait until history/message have been updated
Timothy J. Baek's avatar
Timothy J. Baek committed
135
		await tick();
Timothy J. Baek's avatar
Timothy J. Baek committed
136
137

		// Scroll down
Timothy J. Baek's avatar
Timothy J. Baek committed
138
		window.scrollTo({ top: document.body.scrollHeight });
139

Timothy J. Baek's avatar
Timothy J. Baek committed
140
141
142
143
		const res = await generateChatCompletion(
			$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL,
			localStorage.token,
			{
Timothy J. Baek's avatar
Timothy J. Baek committed
144
145
146
147
148
149
150
151
152
153
154
				model: model,
				messages: [
					$settings.system
						? {
								role: 'system',
								content: $settings.system
						  }
						: undefined,
					...messages
				]
					.filter((message) => message)
Timothy J. Baek's avatar
Timothy J. Baek committed
155
156
157
158
159
160
161
162
163
					.map((message) => ({
						role: message.role,
						content: message.content,
						...(message.files && {
							images: message.files
								.filter((file) => file.type === 'image')
								.map((file) => file.url.slice(file.url.indexOf(',') + 1))
						})
					})),
Timothy J. Baek's avatar
Timothy J. Baek committed
164
165
166
167
				options: {
					...($settings.options ?? {})
				},
				format: $settings.requestFormat ?? undefined
Timothy J. Baek's avatar
Timothy J. Baek committed
168
169
			}
		);
Timothy J. Baek's avatar
Timothy J. Baek committed
170

171
		if (res && res.ok) {
Rohit Das's avatar
Rohit Das committed
172
173
174
175
176
177
178
179
180
181
182
183
			const reader = res.body
				.pipeThrough(new TextDecoderStream())
				.pipeThrough(splitStream('\n'))
				.getReader();

			while (true) {
				const { value, done } = await reader.read();
				if (done || stopResponseFlag || _chatId !== $chatId) {
					responseMessage.done = true;
					messages = messages;
					break;
				}
184

Rohit Das's avatar
Rohit Das committed
185
186
				try {
					let lines = value.split('\n');
187

Rohit Das's avatar
Rohit Das committed
188
189
190
191
					for (const line of lines) {
						if (line !== '') {
							console.log(line);
							let data = JSON.parse(line);
Timothy J. Baek's avatar
Timothy J. Baek committed
192

Rohit Das's avatar
Rohit Das committed
193
194
195
							if ('detail' in data) {
								throw data;
							}
Timothy J. Baek's avatar
Timothy J. Baek committed
196

Rohit Das's avatar
Rohit Das committed
197
198
199
200
201
202
203
							if (data.done == false) {
								if (responseMessage.content == '' && data.message.content == '\n') {
									continue;
								} else {
									responseMessage.content += data.message.content;
									messages = messages;
								}
204
							} else {
Rohit Das's avatar
Rohit Das committed
205
								responseMessage.done = true;
206
207
208
209
210
211
212

								if (responseMessage.content == '') {
									responseMessage.error = true;
									responseMessage.content =
										'Oops! No text generated from Ollama, Please try again.';
								}

Rohit Das's avatar
Rohit Das committed
213
214
215
								responseMessage.context = data.context ?? null;
								responseMessage.info = {
									total_duration: data.total_duration,
Timothy J. Baek's avatar
Timothy J. Baek committed
216
217
218
									load_duration: data.load_duration,
									sample_count: data.sample_count,
									sample_duration: data.sample_duration,
Rohit Das's avatar
Rohit Das committed
219
220
221
222
223
									prompt_eval_count: data.prompt_eval_count,
									prompt_eval_duration: data.prompt_eval_duration,
									eval_count: data.eval_count,
									eval_duration: data.eval_duration
								};
224
								messages = messages;
Timothy J. Baek's avatar
Timothy J. Baek committed
225

Timothy J. Baek's avatar
Timothy J. Baek committed
226
								if ($settings.notificationEnabled && !document.hasFocus()) {
Timothy J. Baek's avatar
Timothy J. Baek committed
227
228
229
230
231
232
233
234
235
236
237
238
239
									const notification = new Notification(
										selectedModelfile
											? `${
													selectedModelfile.title.charAt(0).toUpperCase() +
													selectedModelfile.title.slice(1)
											  }`
											: `Ollama - ${model}`,
										{
											body: responseMessage.content,
											icon: selectedModelfile?.imageUrl ?? '/favicon.png'
										}
									);
								}
Timothy J. Baek's avatar
Timothy J. Baek committed
240
241
242
243

								if ($settings.responseAutoCopy) {
									copyToClipboard(responseMessage.content);
								}
244
245
246
							}
						}
					}
Rohit Das's avatar
Rohit Das committed
247
248
249
250
251
252
				} catch (error) {
					console.log(error);
					if ('detail' in error) {
						toast.error(error.detail);
					}
					break;
253
				}
Rohit Das's avatar
Rohit Das committed
254
255
256

				if (autoScroll) {
					window.scrollTo({ top: document.body.scrollHeight });
257
				}
258
			}
259

260
			if ($chatId == _chatId) {
Timothy J. Baek's avatar
Timothy J. Baek committed
261
				chat = await updateChatById(localStorage.token, _chatId, {
Rohit Das's avatar
Rohit Das committed
262
263
264
					messages: messages,
					history: history
				});
Timothy J. Baek's avatar
Timothy J. Baek committed
265
				await chats.set(await getChatList(localStorage.token));
266
			}
267
268
269
		} else {
			if (res !== null) {
				const error = await res.json();
270
				console.log(error);
271
272
				if ('detail' in error) {
					toast.error(error.detail);
273
					responseMessage.content = error.detail;
274
275
				} else {
					toast.error(error.error);
276
					responseMessage.content = error.error;
277
				}
278
279
			} else {
				toast.error(`Uh-oh! There was an issue connecting to Ollama.`);
280
				responseMessage.content = `Uh-oh! There was an issue connecting to Ollama.`;
281
282
			}

283
284
285
286
			responseMessage.error = true;
			responseMessage.content = `Uh-oh! There was an issue connecting to Ollama.`;
			responseMessage.done = true;
			messages = messages;
287
288
289
290
		}

		stopResponseFlag = false;
		await tick();
Timothy J. Baek's avatar
Timothy J. Baek committed
291

292
293
294
		if (autoScroll) {
			window.scrollTo({ top: document.body.scrollHeight });
		}
295

296
		if (messages.length == 2 && messages.at(1).content !== '') {
Timothy J. Baek's avatar
Timothy J. Baek committed
297
298
			window.history.replaceState(history.state, '', `/c/${_chatId}`);
			await generateChatTitle(_chatId, userPrompt);
299
300
301
		}
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
302
	const sendPromptOpenAI = async (model, userPrompt, parentId, _chatId) => {
Timothy J. Baek's avatar
Timothy J. Baek committed
303
		if ($settings.OPENAI_API_KEY) {
304
			if (models) {
305
306
				let responseMessageId = uuidv4();

307
				let responseMessage = {
308
309
310
					parentId: parentId,
					id: responseMessageId,
					childrenIds: [],
311
					role: 'assistant',
Timothy J. Baek's avatar
Timothy J. Baek committed
312
313
					content: '',
					model: model
314
315
				};

316
317
318
319
320
321
322
323
324
				history.messages[responseMessageId] = responseMessage;
				history.currentId = responseMessageId;
				if (parentId !== null) {
					history.messages[parentId].childrenIds = [
						...history.messages[parentId].childrenIds,
						responseMessageId
					];
				}

325
326
				window.scrollTo({ top: document.body.scrollHeight });

327
328
329
330
331
332
				const res = await fetch(
					`${$settings.OPENAI_API_BASE_URL ?? 'https://api.openai.com/v1'}/chat/completions`,
					{
						method: 'POST',
						headers: {
							Authorization: `Bearer ${$settings.OPENAI_API_KEY}`,
Timothy J. Baek's avatar
Timothy J. Baek committed
333
							'Content-Type': 'application/json'
334
335
336
337
338
339
						},
						body: JSON.stringify({
							model: model,
							stream: true,
							messages: [
								$settings.system
340
									? {
341
342
											role: 'system',
											content: $settings.system
343
									  }
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
									: undefined,
								...messages
							]
								.filter((message) => message)
								.map((message) => ({
									role: message.role,
									...(message.files
										? {
												content: [
													{
														type: 'text',
														text: message.content
													},
													...message.files
														.filter((file) => file.type === 'image')
														.map((file) => ({
															type: 'image_url',
															image_url: {
																url: file.url
															}
														}))
												]
										  }
										: { content: message.content })
								})),
							temperature: $settings.temperature ?? undefined,
							top_p: $settings.top_p ?? undefined,
							num_ctx: $settings.num_ctx ?? undefined,
							frequency_penalty: $settings.repeat_penalty ?? undefined
						})
374
					}
375
376
377
378
				).catch((err) => {
					console.log(err);
					return null;
				});
379

380
381
382
383
384
385
386
387
388
389
390
391
392
				if (res && res.ok) {
					const reader = res.body
						.pipeThrough(new TextDecoderStream())
						.pipeThrough(splitStream('\n'))
						.getReader();

					while (true) {
						const { value, done } = await reader.read();
						if (done || stopResponseFlag || _chatId !== $chatId) {
							responseMessage.done = true;
							messages = messages;
							break;
						}
393

394
395
						try {
							let lines = value.split('\n');
396

397
398
399
400
401
							for (const line of lines) {
								if (line !== '') {
									console.log(line);
									if (line === 'data: [DONE]') {
										responseMessage.done = true;
402
										messages = messages;
403
404
405
406
407
408
409
410
411
412
									} else {
										let data = JSON.parse(line.replace(/^data: /, ''));
										console.log(data);

										if (responseMessage.content == '' && data.choices[0].delta.content == '\n') {
											continue;
										} else {
											responseMessage.content += data.choices[0].delta.content ?? '';
											messages = messages;
										}
413
414
415
									}
								}
							}
416
417
						} catch (error) {
							console.log(error);
418
419
						}

420
421
422
423
424
425
						if ($settings.notificationEnabled && !document.hasFocus()) {
							const notification = new Notification(`OpenAI ${model}`, {
								body: responseMessage.content,
								icon: '/favicon.png'
							});
						}
426

427
428
429
						if ($settings.responseAutoCopy) {
							copyToClipboard(responseMessage.content);
						}
430

431
432
433
						if (autoScroll) {
							window.scrollTo({ top: document.body.scrollHeight });
						}
434
					}
435

436
					if ($chatId == _chatId) {
Timothy J. Baek's avatar
Timothy J. Baek committed
437
						chat = await updateChatById(localStorage.token, _chatId, {
438
439
440
							messages: messages,
							history: history
						});
Timothy J. Baek's avatar
Timothy J. Baek committed
441
						await chats.set(await getChatList(localStorage.token));
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
					}
				} else {
					if (res !== null) {
						const error = await res.json();
						console.log(error);
						if ('detail' in error) {
							toast.error(error.detail);
							responseMessage.content = error.detail;
						} else {
							if ('message' in error.error) {
								toast.error(error.error.message);
								responseMessage.content = error.error.message;
							} else {
								toast.error(error.error);
								responseMessage.content = error.error;
							}
						}
					} else {
						toast.error(`Uh-oh! There was an issue connecting to ${model}.`);
						responseMessage.content = `Uh-oh! There was an issue connecting to ${model}.`;
					}
Timothy J. Baek's avatar
Timothy J. Baek committed
463

464
465
466
467
					responseMessage.error = true;
					responseMessage.content = `Uh-oh! There was an issue connecting to ${model}.`;
					responseMessage.done = true;
					messages = messages;
Timothy J. Baek's avatar
Timothy J. Baek committed
468
469
				}

470
471
				stopResponseFlag = false;
				await tick();
Timothy J. Baek's avatar
Timothy J. Baek committed
472

473
474
475
476
477
				if (autoScroll) {
					window.scrollTo({ top: document.body.scrollHeight });
				}

				if (messages.length == 2) {
Timothy J. Baek's avatar
Timothy J. Baek committed
478
479
					window.history.replaceState(history.state, '', `/c/${_chatId}`);
					await setChatTitle(_chatId, userPrompt);
480
481
482
				}
			}
		}
483
484
485
	};

	const submitPrompt = async (userPrompt) => {
486
		console.log('submitPrompt', $chatId);
487

Timothy J. Baek's avatar
Timothy J. Baek committed
488
		if (selectedModels.includes('')) {
Timothy J. Baek's avatar
Timothy J. Baek committed
489
			toast.error('Model not selected');
490
		} else if (messages.length != 0 && messages.at(-1).done != true) {
Timothy J. Baek's avatar
Timothy J. Baek committed
491
			// Response not done
Timothy J. Baek's avatar
Timothy J. Baek committed
492
493
			console.log('wait');
		} else {
Timothy J. Baek's avatar
Timothy J. Baek committed
494
			// Reset chat message textarea height
Timothy J. Baek's avatar
Timothy J. Baek committed
495
496
			document.getElementById('chat-textarea').style.height = '';

Timothy J. Baek's avatar
Timothy J. Baek committed
497
			// Create user message
Timothy J. Baek's avatar
Timothy J. Baek committed
498
499
500
501
502
503
			let userMessageId = uuidv4();
			let userMessage = {
				id: userMessageId,
				parentId: messages.length !== 0 ? messages.at(-1).id : null,
				childrenIds: [],
				role: 'user',
504
505
				content: userPrompt,
				files: files.length > 0 ? files : undefined
Timothy J. Baek's avatar
Timothy J. Baek committed
506
507
			};

Timothy J. Baek's avatar
Timothy J. Baek committed
508
509
510
511
512
			// Add message to history and Set currentId to messageId
			history.messages[userMessageId] = userMessage;
			history.currentId = userMessageId;

			// Append messageId to childrenIds of parent message
Timothy J. Baek's avatar
Timothy J. Baek committed
513
514
515
516
			if (messages.length !== 0) {
				history.messages[messages.at(-1).id].childrenIds.push(userMessageId);
			}

Timothy J. Baek's avatar
Timothy J. Baek committed
517
			// Wait until history/message have been updated
Timothy J. Baek's avatar
Timothy J. Baek committed
518
			await tick();
519

Timothy J. Baek's avatar
Timothy J. Baek committed
520
			// Create new chat if only one message in messages
Timothy J. Baek's avatar
Timothy J. Baek committed
521
			if (messages.length == 1) {
Timothy J. Baek's avatar
Timothy J. Baek committed
522
				chat = await createNewChat(localStorage.token, {
523
					id: $chatId,
524
					title: 'New Chat',
Timothy J. Baek's avatar
Timothy J. Baek committed
525
					models: selectedModels,
526
					system: $settings.system ?? undefined,
527
					options: {
528
						...($settings.options ?? {})
529
					},
Timothy J. Baek's avatar
Timothy J. Baek committed
530
					messages: messages,
Timothy J. Baek's avatar
Timothy J. Baek committed
531
532
					history: history,
					timestamp: Date.now()
533
				});
Timothy J. Baek's avatar
Timothy J. Baek committed
534
				await chats.set(await getChatList(localStorage.token));
535
536
				await chatId.set(chat.id);
				await tick();
537
			}
538

Timothy J. Baek's avatar
Timothy J. Baek committed
539
			// Reset chat input textarea
Timothy J. Baek's avatar
Timothy J. Baek committed
540
541
542
			prompt = '';
			files = [];

Timothy J. Baek's avatar
Timothy J. Baek committed
543
			// Send prompt
544
			await sendPrompt(userPrompt, userMessageId);
Timothy J. Baek's avatar
Timothy J. Baek committed
545
546
547
		}
	};

548
549
550
551
552
	const stopResponse = () => {
		stopResponseFlag = true;
		console.log('stopResponse');
	};

553
	const regenerateResponse = async () => {
Timothy J. Baek's avatar
Timothy J. Baek committed
554
		console.log('regenerateResponse');
555
556
557
		if (messages.length != 0 && messages.at(-1).done == true) {
			messages.splice(messages.length - 1, 1);
			messages = messages;
Timothy J. Baek's avatar
Timothy J. Baek committed
558

559
560
			let userMessage = messages.at(-1);
			let userPrompt = userMessage.content;
561

Timothy J. Baek's avatar
Timothy J. Baek committed
562
			await sendPrompt(userPrompt, userMessage.id);
Timothy J. Baek's avatar
Timothy J. Baek committed
563
		}
564
	};
565

566
	const generateChatTitle = async (_chatId, userPrompt) => {
567
		if ($settings.titleAutoGenerate ?? true) {
Timothy J. Baek's avatar
Timothy J. Baek committed
568
569
570
571
572
573
574
575
576
			const title = await generateTitle(
				$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL,
				localStorage.token,
				selectedModels[0],
				userPrompt
			);

			if (title) {
				await setChatTitle(_chatId, title);
577
578
579
			}
		} else {
			await setChatTitle(_chatId, `${userPrompt}`);
580
581
582
583
		}
	};

	const setChatTitle = async (_chatId, _title) => {
584
		if (_chatId === $chatId) {
585
			title = _title;
586
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
587
588
589

		chat = await updateChatById(localStorage.token, _chatId, { title: _title });
		await chats.set(await getChatList(localStorage.token));
590
	};
Timothy J. Baek's avatar
Timothy J. Baek committed
591
592
</script>

593
594
<svelte:window
	on:scroll={(e) => {
Timothy J. Baek's avatar
Timothy J. Baek committed
595
		autoScroll = window.innerHeight + window.scrollY >= document.body.offsetHeight - 40;
596
597
598
	}}
/>

599
<Navbar {title} shareEnabled={messages.length > 0} {initNewChat} />
600
601
602
603
<div class="min-h-screen w-full flex justify-center">
	<div class=" py-2.5 flex flex-col justify-between w-full">
		<div class="max-w-2xl mx-auto w-full px-3 md:px-0 mt-10">
			<ModelSelector bind:selectedModels disabled={messages.length > 0} />
Timothy J. Baek's avatar
Timothy J. Baek committed
604
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
605

606
		<div class=" h-full mt-10 mb-32 w-full flex flex-col">
607
			<Messages
608
				chatId={$chatId}
609
610
611
612
613
				{selectedModels}
				{selectedModelfile}
				bind:history
				bind:messages
				bind:autoScroll
Timothy J. Baek's avatar
Timothy J. Baek committed
614
				bottomPadding={files.length > 0}
615
616
617
				{sendPrompt}
				{regenerateResponse}
			/>
618
619
		</div>
	</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
620

621
622
	<MessageInput
		bind:files
Timothy J. Baek's avatar
Timothy J. Baek committed
623
		bind:prompt
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
		bind:autoScroll
		suggestionPrompts={selectedModelfile?.suggestionPrompts ?? [
			{
				title: ['Help me study', 'vocabulary for a college entrance exam'],
				content: `Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option.`
			},
			{
				title: ['Give me ideas', `for what to do with my kids' art`],
				content: `What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter.`
			},
			{
				title: ['Tell me a fun fact', 'about the Roman Empire'],
				content: 'Tell me a random fun fact about the Roman Empire'
			},
			{
				title: ['Show me a code snippet', `of a website's sticky header`],
				content: `Show me a code snippet of a website's sticky header in CSS and JavaScript.`
			}
		]}
		{messages}
		{submitPrompt}
		{stopResponse}
	/>
647
</div>