From 18872692070323b2e3c198c58b63b36d60876d18 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 27 Oct 2023 23:40:54 -0700 Subject: [PATCH 1/2] feat: message rating added for research purposes --- src/routes/+page.svelte | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 8d8d9946..c0fbd557 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -291,6 +291,29 @@ console.log(messages); }; + const rateMessage = async (messageIdx, rating) => { + messages = messages.map((message, idx) => { + if (messageIdx === idx) { + message.rating = rating; + } + return message; + }); + + await db.put('chats', { + id: chatId, + title: title === '' ? 'New Chat' : title, + model: selectedModel, + system: system, + options: { + temperature: temperature + }, + timestamp: Date.now(), + messages: messages + }); + + console.log(messages); + }; + ////////////////////////// // Ollama functions ////////////////////////// @@ -738,6 +761,55 @@ {/if} {:else} {@html marked.parse(message.content)} + + {#if message.done} +
+ + +
+ {/if} {/if} {/if} From 2b3069a6136fbce29f415c235da2c8d364d6dfaa Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 28 Oct 2023 00:55:34 -0700 Subject: [PATCH 2/2] feat: chat title edit --- src/lib/components/layout/Navbar.svelte | 195 ++++++++++++++++++++---- src/routes/+page.svelte | 24 +++ 2 files changed, 186 insertions(+), 33 deletions(-) diff --git a/src/lib/components/layout/Navbar.svelte b/src/lib/components/layout/Navbar.svelte index 28503a70..4784a5ee 100644 --- a/src/lib/components/layout/Navbar.svelte +++ b/src/lib/components/layout/Navbar.svelte @@ -6,18 +6,30 @@ let importFileInputElement; let importFiles; + export let selectedChatId = ''; export let title: string = 'Ollama Web UI'; export let chats = []; export let createNewChat: Function; export let loadChat: Function; + export let deleteChat: Function; + export let editChatTitle: Function; export let importChatHistory: Function; export let exportChatHistory: Function; export let deleteChatHistory: Function; export let openSettings: Function; + let chatTitleEditIdx = null; + let chatTitle = ''; + + let _chats = chats.map((item, idx) => chats[chats.length - 1 - idx]); + onMount(() => {}); + $: if (chats) { + _chats = chats.map((item, idx) => chats[chats.length - 1 - idx]); + } + $: if (importFiles) { console.log(importFiles); @@ -99,8 +111,8 @@ : '-translate-x-72'} w-72 fixed top-0 left-0 z-40 transition bg-gray-900 text-gray-200 shadow-2xl text-sm " > -
-
+
+
-
- {#each chats.reverse() as chat, i} - +
+ {#each _chats as chat, i} +
+ + + {#if chat.id === selectedChatId} +
+ {#if chatTitleEditIdx === chat.id} +
+ + +
+ {:else} +
+ + +
+ {/if} +
+ {/if} +
{/each}
-
+