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
6a2c1600
Commit
6a2c1600
authored
Nov 19, 2023
by
Timothy J. Baek
Browse files
fix: new chat load
parent
e1160165
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
21 deletions
+37
-21
src/lib/components/chat/SettingsModal.svelte
src/lib/components/chat/SettingsModal.svelte
+4
-2
src/lib/components/layout/Navbar.svelte
src/lib/components/layout/Navbar.svelte
+7
-2
src/lib/components/layout/Sidebar.svelte
src/lib/components/layout/Sidebar.svelte
+6
-2
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+5
-4
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+15
-11
No files found.
src/lib/components/chat/SettingsModal.svelte
View file @
6a2c1600
...
@@ -50,10 +50,12 @@
...
@@ -50,10 +50,12 @@
if (API_BASE_URL === '') {
if (API_BASE_URL === '') {
API_BASE_URL = BUILD_TIME_API_BASE_URL;
API_BASE_URL = BUILD_TIME_API_BASE_URL;
}
}
const
re
s = await getModels(API_BASE_URL, 'ollama');
const
_model
s = await getModels(API_BASE_URL, 'ollama');
if (
res
) {
if (
_models.length > 0
) {
toast.success('Server connection verified');
toast.success('Server connection verified');
await models.set(_models);
saveSettings({
saveSettings({
API_BASE_URL: API_BASE_URL
API_BASE_URL: API_BASE_URL
});
});
...
...
src/lib/components/layout/Navbar.svelte
View file @
6a2c1600
<script lang="ts">
<script lang="ts">
import { v4 as uuidv4 } from 'uuid';
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { chatId } from '$lib/stores';
export let title: string = 'Ollama Web UI';
export let title: string = 'Ollama Web UI';
</script>
</script>
...
@@ -14,8 +17,10 @@
...
@@ -14,8 +17,10 @@
<div class="pr-2">
<div class="pr-2">
<button
<button
class=" cursor-pointer p-1 flex dark:hover:bg-gray-700 rounded-lg transition"
class=" cursor-pointer p-1 flex dark:hover:bg-gray-700 rounded-lg transition"
on:click={() => {
on:click={async () => {
location.href = '/';
console.log('newChat');
goto('/');
await chatId.set(uuidv4());
}}
}}
>
>
<div class=" m-auto self-center">
<div class=" m-auto self-center">
...
...
src/lib/components/layout/Sidebar.svelte
View file @
6a2c1600
<script lang="ts">
<script lang="ts">
import { v4 as uuidv4 } from 'uuid';
import { goto, invalidateAll } from '$app/navigation';
import { goto, invalidateAll } from '$app/navigation';
import { page } from '$app/stores';
import { page } from '$app/stores';
import { user, db, chats, showSettings, chatId } from '$lib/stores';
import { user, db, chats, showSettings, chatId } from '$lib/stores';
...
@@ -168,8 +170,10 @@
...
@@ -168,8 +170,10 @@
<div class="px-2.5 flex justify-center space-x-2">
<div class="px-2.5 flex justify-center space-x-2">
<button
<button
class="flex-grow flex justify-between rounded-md px-3 py-1.5 my-2 hover:bg-gray-900 transition"
class="flex-grow flex justify-between rounded-md px-3 py-1.5 my-2 hover:bg-gray-900 transition"
on:click={() => {
on:click={async () => {
location.href = '/';
goto('/');
await chatId.set(uuidv4());
// createNewChat();
// createNewChat();
}}
}}
>
>
...
...
src/routes/(app)/+page.svelte
View file @
6a2c1600
...
@@ -41,8 +41,11 @@
...
@@ -41,8 +41,11 @@
}
}
onMount(async () => {
onMount(async () => {
console.log();
await chatId.set(uuidv4());
await initNewChat();
chatId.subscribe(async () => {
await initNewChat();
});
});
});
//////////////////////////
//////////////////////////
...
@@ -50,8 +53,6 @@
...
@@ -50,8 +53,6 @@
//////////////////////////
//////////////////////////
const initNewChat = async () => {
const initNewChat = async () => {
await chatId.set(uuidv4());
console.log($chatId);
console.log($chatId);
autoScroll = true;
autoScroll = true;
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
6a2c1600
...
@@ -91,6 +91,8 @@
...
@@ -91,6 +91,8 @@
if (messages.length > 0) {
if (messages.length > 0) {
history.messages[messages.at(-1).id].done = true;
history.messages[messages.at(-1).id].done = true;
}
}
await tick();
return chat;
return chat;
} else {
} else {
return null;
return null;
...
@@ -503,17 +505,19 @@
...
@@ -503,17 +505,19 @@
}}
}}
/>
/>
<Navbar {title} />
{#if loaded}
<div class="min-h-screen w-full flex justify-center">
<Navbar {title} />
<div class=" py-2.5 flex flex-col justify-between w-full">
<div class="min-h-screen w-full flex justify-center">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 mt-10">
<div class=" py-2.5 flex flex-col justify-between w-full">
<ModelSelector bind:selectedModels disabled={messages.length > 0} />
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 mt-10">
<ModelSelector bind:selectedModels disabled={messages.length > 0} />
</div>
<div class=" h-full mt-10 mb-32 w-full flex flex-col">
<Messages bind:history bind:messages bind:autoScroll {sendPrompt} {regenerateResponse} />
</div>
</div>
</div>
<div class=" h-full mt-10 mb-32 w-full flex flex-col">
<MessageInput bind:prompt bind:autoScroll {messages} {submitPrompt} {stopResponse} />
<Messages bind:history bind:messages bind:autoScroll {sendPrompt} {regenerateResponse} />
</div>
</div>
</div>
{/if}
<MessageInput bind:prompt bind:autoScroll {messages} {submitPrompt} {stopResponse} />
</div>
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