Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
18872692
Commit
18872692
authored
Oct 27, 2023
by
Timothy J. Baek
Browse files
feat: message rating added for research purposes
parent
81d54b46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
src/routes/+page.svelte
src/routes/+page.svelte
+72
-0
No files found.
src/routes/+page.svelte
View file @
18872692
...
...
@@ -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}
<div
class=
" flex justify-end space-x-1 text-gray-400"
>
<button
class=
"p-1 rounded hover:bg-gray-800 {message.rating === 1
? 'bg-gray-800'
: ''} transition"
on:click=
{()
=
>
{
rateMessage(messageIdx, 1);
}}
>
<svg
stroke=
"currentColor"
fill=
"none"
stroke-width=
"2"
viewBox=
"0 0 24 24"
stroke-linecap=
"round"
stroke-linejoin=
"round"
class=
"w-4 h-4"
xmlns=
"http://www.w3.org/2000/svg"
><path
d=
"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"
/></svg
>
</button>
<button
class=
"p-1 rounded hover:bg-gray-800 {message.rating === -1
? 'bg-gray-800'
: ''} transition"
on:click=
{()
=
>
{
rateMessage(messageIdx, -1);
}}
>
<svg
stroke=
"currentColor"
fill=
"none"
stroke-width=
"2"
viewBox=
"0 0 24 24"
stroke-linecap=
"round"
stroke-linejoin=
"round"
class=
"w-4 h-4"
xmlns=
"http://www.w3.org/2000/svg"
><path
d=
"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"
/></svg
>
</button>
</div>
{/if}
{/if}
</div>
{/if}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment