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
74da8ebf
Unverified
Commit
74da8ebf
authored
Jan 17, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jan 17, 2024
Browse files
Merge pull request #505 from ollama-webui/message-ts
feat: message ts
parents
89b35e45
cf88652a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
18 deletions
+34
-18
src/lib/components/chat/Messages/Name.svelte
src/lib/components/chat/Messages/Name.svelte
+1
-1
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+7
-0
src/lib/components/chat/Messages/UserMessage.svelte
src/lib/components/chat/Messages/UserMessage.svelte
+8
-0
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+6
-3
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+12
-14
No files found.
src/lib/components/chat/Messages/Name.svelte
View file @
74da8ebf
<div class=" self-center font-bold mb-0.5 capitalize">
<div class=" self-center font-bold mb-0.5 capitalize
line-clamp-1
">
<slot />
<slot />
</div>
</div>
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
74da8ebf
<script
lang=
"ts"
>
<script
lang=
"ts"
>
import
dayjs
from
'
dayjs
'
;
import
{
marked
}
from
'
marked
'
;
import
{
marked
}
from
'
marked
'
;
import
tippy
from
'
tippy.js
'
;
import
tippy
from
'
tippy.js
'
;
...
@@ -219,6 +220,12 @@
...
@@ -219,6 +220,12 @@
>
{message.model ? ` ${message.model}` : ''}
</span
>
{message.model ? ` ${message.model}` : ''}
</span
>
>
{/if}
{/if}
{#if message.timestamp}
<span
class=
" invisible group-hover:visible text-gray-400 text-xs font-medium"
>
{dayjs(message.timestamp * 1000).format('DD/MM/YYYY HH:MM')}
</span>
{/if}
</Name>
</Name>
{#if message.content === ''}
{#if message.content === ''}
...
...
src/lib/components/chat/Messages/UserMessage.svelte
View file @
74da8ebf
<script lang="ts">
<script lang="ts">
import dayjs from 'dayjs';
import { tick } from 'svelte';
import { tick } from 'svelte';
import Name from './Name.svelte';
import Name from './Name.svelte';
import ProfileImage from './ProfileImage.svelte';
import ProfileImage from './ProfileImage.svelte';
...
@@ -61,6 +63,12 @@
...
@@ -61,6 +63,12 @@
{:else}
{:else}
You
You
{/if}
{/if}
{#if message.timestamp}
<span class=" invisible group-hover:visible text-gray-400 text-xs font-medium">
{dayjs(message.timestamp * 1000).format('DD/MM/YYYY HH:MM')}
</span>
{/if}
</Name>
</Name>
</div>
</div>
...
...
src/routes/(app)/+page.svelte
View file @
74da8ebf
...
@@ -145,7 +145,8 @@
...
@@ -145,7 +145,8 @@
role: 'user',
role: 'user',
user: _user ?? undefined,
user: _user ?? undefined,
content: userPrompt,
content: userPrompt,
files: files.length > 0 ? files : undefined
files: files.length > 0 ? files : undefined,
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
};
// Add message to history and Set currentId to messageId
// Add message to history and Set currentId to messageId
...
@@ -256,7 +257,8 @@
...
@@ -256,7 +257,8 @@
childrenIds: [],
childrenIds: [],
role: 'assistant',
role: 'assistant',
content: '',
content: '',
model: model
model: model,
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
};
// Add message to history and Set currentId to messageId
// Add message to history and Set currentId to messageId
...
@@ -446,7 +448,8 @@
...
@@ -446,7 +448,8 @@
childrenIds: [],
childrenIds: [],
role: 'assistant',
role: 'assistant',
content: '',
content: '',
model: model
model: model,
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
};
history.messages[responseMessageId] = responseMessage;
history.messages[responseMessageId] = responseMessage;
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
74da8ebf
...
@@ -135,8 +135,7 @@
...
@@ -135,8 +135,7 @@
// Ollama functions
// Ollama functions
//////////////////////////
//////////////////////////
const submitPrompt = async (userPrompt, user) => {
const submitPrompt = async (userPrompt, _user = null) => {
console.log(userPrompt, user);
console.log('submitPrompt', $chatId);
console.log('submitPrompt', $chatId);
if (selectedModels.includes('')) {
if (selectedModels.includes('')) {
...
@@ -163,8 +162,10 @@
...
@@ -163,8 +162,10 @@
parentId: messages.length !== 0 ? messages.at(-1).id : null,
parentId: messages.length !== 0 ? messages.at(-1).id : null,
childrenIds: [],
childrenIds: [],
role: 'user',
role: 'user',
user: _user ?? undefined,
content: userPrompt,
content: userPrompt,
files: files.length > 0 ? files : undefined
files: files.length > 0 ? files : undefined,
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
};
// Add message to history and Set currentId to messageId
// Add message to history and Set currentId to messageId
...
@@ -200,15 +201,7 @@
...
@@ -200,15 +201,7 @@
await chatId.set('local');
await chatId.set('local');
}
}
await tick();
await tick();
} else if (chat.chat["models"] != selectedModels) {
// If model is not saved in DB, then save selectedmodel when message is sent
chat = await updateChatById(localStorage.token, $chatId, {
models: selectedModels
});
await chats.set(await getChatList(localStorage.token));
}
}
// Reset chat input textarea
// Reset chat input textarea
prompt = '';
prompt = '';
files = [];
files = [];
...
@@ -282,7 +275,8 @@
...
@@ -282,7 +275,8 @@
childrenIds: [],
childrenIds: [],
role: 'assistant',
role: 'assistant',
content: '',
content: '',
model: model
model: model,
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
};
// Add message to history and Set currentId to messageId
// Add message to history and Set currentId to messageId
...
@@ -472,7 +466,8 @@
...
@@ -472,7 +466,8 @@
childrenIds: [],
childrenIds: [],
role: 'assistant',
role: 'assistant',
content: '',
content: '',
model: model
model: model,
timestamp: Math.floor(Date.now() / 1000) // Unix epoch
};
};
history.messages[responseMessageId] = responseMessage;
history.messages[responseMessageId] = responseMessage;
...
@@ -703,7 +698,10 @@
...
@@ -703,7 +698,10 @@
<div class="min-h-screen w-full flex justify-center">
<div class="min-h-screen w-full flex justify-center">
<div class=" py-2.5 flex flex-col justify-between w-full">
<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">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 mt-10">
<ModelSelector bind:selectedModels disabled={messages.length > 0 && !selectedModels.includes('')} />
<ModelSelector
bind:selectedModels
disabled={messages.length > 0 && !selectedModels.includes('')}
/>
</div>
</div>
<div class=" h-full mt-10 mb-32 w-full flex flex-col">
<div class=" h-full mt-10 mb-32 w-full flex flex-col">
...
...
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