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
46774aa5
Unverified
Commit
46774aa5
authored
Apr 03, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Apr 03, 2024
Browse files
Merge pull request #1416 from open-webui/dev
0.1.117
parents
5558514f
62392aa8
Changes
45
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
284 additions
and
96 deletions
+284
-96
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+2
-1
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+2
-1
src/routes/auth/+page.svelte
src/routes/auth/+page.svelte
+100
-78
src/routes/s/[id]/+page.svelte
src/routes/s/[id]/+page.svelte
+180
-0
static/manifest.json
static/manifest.json
+0
-16
No files found.
src/routes/(app)/+page.svelte
View file @
46774aa5
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
let
messagesContainerElement
:
HTMLDivElement
;
let
messagesContainerElement
:
HTMLDivElement
;
let
currentRequestId
=
null
;
let
currentRequestId
=
null
;
let
showModelSelector
=
fals
e
;
let
showModelSelector
=
tru
e
;
let
selectedModels
=
[
''
];
let
selectedModels
=
[
''
];
let
selectedModelfile
=
null
;
let
selectedModelfile
=
null
;
...
@@ -847,6 +847,7 @@
...
@@ -847,6 +847,7 @@
bind
:
selectedModels
bind
:
selectedModels
bind
:
showModelSelector
bind
:
showModelSelector
shareEnabled
={
messages
.
length
>
0
}
shareEnabled
={
messages
.
length
>
0
}
{
chat
}
{
initNewChat
}
{
initNewChat
}
{
tags
}
{
tags
}
{
addTag
}
{
addTag
}
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
46774aa5
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
let
currentRequestId
=
null
;
let
currentRequestId
=
null
;
//
let
chatId
=
$
page
.
params
.
id
;
//
let
chatId
=
$
page
.
params
.
id
;
let
showModelSelector
=
fals
e
;
let
showModelSelector
=
tru
e
;
let
selectedModels
=
[
''
];
let
selectedModels
=
[
''
];
let
selectedModelfile
=
null
;
let
selectedModelfile
=
null
;
...
@@ -865,6 +865,7 @@
...
@@ -865,6 +865,7 @@
<
div
class
=
"min-h-screen max-h-screen w-full flex flex-col"
>
<
div
class
=
"min-h-screen max-h-screen w-full flex flex-col"
>
<
Navbar
<
Navbar
{
title
}
{
title
}
{
chat
}
bind
:
selectedModels
bind
:
selectedModels
bind
:
showModelSelector
bind
:
showModelSelector
shareEnabled
={
messages
.
length
>
0
}
shareEnabled
={
messages
.
length
>
0
}
...
...
src/routes/auth/+page.svelte
View file @
46774aa5
<script>
<script>
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { userSignIn, userSignUp } from '$lib/apis/auths';
import { userSignIn, userSignUp } from '$lib/apis/auths';
import Spinner from '$lib/components/common/Spinner.svelte';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { WEBUI_NAME, config, user } from '$lib/stores';
import { WEBUI_NAME, config, user } from '$lib/stores';
import { onMount, getContext } from 'svelte';
import { onMount, getContext } from 'svelte';
...
@@ -56,6 +57,9 @@
...
@@ -56,6 +57,9 @@
await goto('/');
await goto('/');
}
}
loaded = true;
loaded = true;
if ($config?.trusted_header_auth ?? false) {
await signInHandler();
}
});
});
</script>
</script>
...
@@ -90,100 +94,118 @@
...
@@ -90,100 +94,118 @@
</div> -->
</div> -->
<div class="w-full sm:max-w-lg px-4 min-h-screen flex flex-col">
<div class="w-full sm:max-w-lg px-4 min-h-screen flex flex-col">
<div class=" my-auto pb-10 w-full">
{#if $config?.trusted_header_auth ?? false}
<form
<div class=" my-auto pb-10 w-full">
class=" flex flex-col justify-center bg-white py-6 sm:py-16 px-6 sm:px-16 rounded-2xl"
<div
on:submit|preventDefault={() => {
class="flex items-center justify-center gap-3 text-xl sm:text-2xl text-center font-bold dark:text-gray-200"
submitHandler();
>
}}
<div>
>
{$i18n.t('Signing in')}
<div class=" text-xl sm:text-2xl font-bold">
{$i18n.t('to')}
{mode === 'signin' ? $i18n.t('Sign in') : $i18n.t('Sign up')}
{$WEBUI_NAME}
{$i18n.t('to')}
</div>
{$WEBUI_NAME}
</div>
{#if mode === 'signup'}
<div>
<div class=" mt-1 text-xs font-medium text-gray-500">
<Spinner />
ⓘ {$WEBUI_NAME}
</div>
{$i18n.t(
</div>
'does not make any external connections, and your data stays securely on your locally hosted server.'
</div>
)}
{:else}
<div class=" my-auto pb-10 w-full">
<form
class=" flex flex-col justify-center bg-white py-6 sm:py-16 px-6 sm:px-16 rounded-2xl"
on:submit|preventDefault={() => {
submitHandler();
}}
>
<div class=" text-xl sm:text-2xl font-bold">
{mode === 'signin' ? $i18n.t('Sign in') : $i18n.t('Sign up')}
{$i18n.t('to')}
{$WEBUI_NAME}
</div>
</div>
{/if}
<div class="flex flex-col mt-4">
{#if mode === 'signup'}
{#if mode === 'signup'}
<div>
<div class=" mt-1 text-xs font-medium text-gray-500">
<div class=" text-sm font-semibold text-left mb-1">{$i18n.t('Name')}</div>
ⓘ {$WEBUI_NAME}
{$i18n.t(
'does not make any external connections, and your data stays securely on your locally hosted server.'
)}
</div>
{/if}
<div class="flex flex-col mt-4">
{#if mode === 'signup'}
<div>
<div class=" text-sm font-semibold text-left mb-1">{$i18n.t('Name')}</div>
<input
bind:value={name}
type="text"
class=" border px-4 py-2.5 rounded-2xl w-full text-sm"
autocomplete="name"
placeholder={$i18n.t('Enter Your Full Name')}
required
/>
</div>
<hr class=" my-3" />
{/if}
<div class="mb-2">
<div class=" text-sm font-semibold text-left mb-1">{$i18n.t('Email')}</div>
<input
<input
bind:value={
name
}
bind:value={
email
}
type="
text
"
type="
email
"
class=" border px-4 py-2.5 rounded-2xl w-full text-sm"
class=" border px-4 py-2.5 rounded-2xl w-full text-sm"
autocomplete="
name
"
autocomplete="
email
"
placeholder={$i18n.t('Enter Your
Full Name
')}
placeholder={$i18n.t('Enter Your
Email
')}
required
required
/>
/>
</div>
</div>
<hr class=" my-3" />
<div>
{/if}
<div class=" text-sm font-semibold text-left mb-1">{$i18n.t('Password')}</div>
<input
<div class="mb-2">
bind:value={password}
<div class=" text-sm font-semibold text-left mb-1">{$i18n.t('Email')}</div>
type="password"
<input
class=" border px-4 py-2.5 rounded-2xl w-full text-sm"
bind:value={email}
placeholder={$i18n.t('Enter Your Password')}
type="email"
autocomplete="current-password"
class=" border px-4 py-2.5 rounded-2xl w-full text-sm"
required
autocomplete="email"
/>
placeholder={$i18n.t('Enter Your Email')}
</div>
required
/>
</div>
<div>
<div class=" text-sm font-semibold text-left mb-1">{$i18n.t('Password')}</div>
<input
bind:value={password}
type="password"
class=" border px-4 py-2.5 rounded-2xl w-full text-sm"
placeholder={$i18n.t('Enter Your Password')}
autocomplete="current-password"
required
/>
</div>
</div>
</div>
<div class="mt-5">
<button
class=" bg-gray-900 hover:bg-gray-800 w-full rounded-full text-white font-semibold text-sm py-3 transition"
type="submit"
>
{mode === 'signin' ? $i18n.t('Sign in') : $i18n.t('Create Account')}
</button>
<div class=" mt-4 text-sm text-center">
{mode === 'signin'
? $i18n.t("Don't have an account?")
: $i18n.t('Already have an account?')}
<div class="mt-5">
<button
<button
class=" font-medium underline"
class=" bg-gray-900 hover:bg-gray-800 w-full rounded-full text-white font-semibold text-sm py-3 transition"
type="button"
type="submit"
on:click={() => {
if (mode === 'signin') {
mode = 'signup';
} else {
mode = 'signin';
}
}}
>
>
{mode === 'signin' ? $i18n.t('Sign
up
') : $i18n.t('
Sign in
')}
{mode === 'signin' ? $i18n.t('Sign
in
') : $i18n.t('
Create Account
')}
</button>
</button>
<div class=" mt-4 text-sm text-center">
{mode === 'signin'
? $i18n.t("Don't have an account?")
: $i18n.t('Already have an account?')}
<button
class=" font-medium underline"
type="button"
on:click={() => {
if (mode === 'signin') {
mode = 'signup';
} else {
mode = 'signin';
}
}}
>
{mode === 'signin' ? $i18n.t('Sign up') : $i18n.t('Sign in')}
</button>
</div>
</div>
</div>
</
div
>
</
form
>
</
form
>
</
div
>
</div>
{/if}
</div>
</div>
</div>
</div>
{/if}
{/if}
...
...
src/routes/s/[id]/+page.svelte
0 → 100644
View file @
46774aa5
<script lang="ts">
import { onMount, tick, getContext } from 'svelte';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import dayjs from 'dayjs';
import { modelfiles, settings, chatId, WEBUI_NAME } from '$lib/stores';
import { convertMessagesToHistory } from '$lib/utils';
import { getChatByShareId } from '$lib/apis/chats';
import Messages from '$lib/components/chat/Messages.svelte';
import Navbar from '$lib/components/layout/Navbar.svelte';
const i18n = getContext('i18n');
let loaded = false;
let autoScroll = true;
let processing = '';
let messagesContainerElement: HTMLDivElement;
// let chatId = $page.params.id;
let showModelSelector = false;
let selectedModels = [''];
let selectedModelfiles = {};
$: selectedModelfiles = selectedModels.reduce((a, tagName, i, arr) => {
const modelfile =
$modelfiles.filter((modelfile) => modelfile.tagName === tagName)?.at(0) ?? undefined;
return {
...a,
...(modelfile && { [tagName]: modelfile })
};
}, {});
let chat = null;
let title = '';
let files = [];
let messages = [];
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;
} else {
messages = [];
}
$: if ($page.params.id) {
(async () => {
if (await loadSharedChat()) {
await tick();
loaded = true;
window.setTimeout(() => scrollToBottom(), 0);
const chatInput = document.getElementById('chat-textarea');
chatInput?.focus();
} else {
await goto('/');
}
})();
}
//////////////////////////
// Web functions
//////////////////////////
const loadSharedChat = async () => {
await chatId.set($page.params.id);
chat = await getChatByShareId(localStorage.token, $chatId).catch(async (error) => {
await goto('/');
return null;
});
if (chat) {
const chatContent = chat.chat;
if (chatContent) {
console.log(chatContent);
selectedModels =
(chatContent?.models ?? undefined) !== undefined
? chatContent.models
: [chatContent.models ?? ''];
history =
(chatContent?.history ?? undefined) !== undefined
? chatContent.history
: convertMessagesToHistory(chatContent.messages);
title = chatContent.title;
let _settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
await settings.set({
..._settings,
system: chatContent.system ?? _settings.system,
options: chatContent.options ?? _settings.options
});
autoScroll = true;
await tick();
if (messages.length > 0) {
history.messages[messages.at(-1).id].done = true;
}
await tick();
return true;
} else {
return null;
}
}
};
</script>
<svelte:head>
<title>
{title
? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}`
: `${$WEBUI_NAME}`}
</title>
</svelte:head>
{#if loaded}
<div
class="min-h-screen max-h-screen w-full flex flex-col text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-900"
>
<div class="flex flex-col flex-auto justify-center py-8">
<div class="px-3 w-full max-w-3xl mx-auto">
<div>
<div class=" text-3xl font-semibold line-clamp-1">
{title}
</div>
<div class=" mt-1 text-gray-400">
{dayjs(chat.chat.timestamp).format('MMMM D, YYYY')}
</div>
</div>
<hr class=" dark:border-gray-800 mt-6 mb-2" />
</div>
<div
class=" flex flex-col justify-center w-full flex-auto overflow-auto h-0"
id="messages-container"
>
<div class=" h-full w-full flex flex-col py-4">
<div class="py-2">
<Messages
chatId={$chatId}
readOnly={true}
{selectedModels}
{selectedModelfiles}
{processing}
bind:history
bind:messages
bind:autoScroll
bottomPadding={files.length > 0}
sendPrompt={() => {}}
continueGeneration={() => {}}
regenerateResponse={() => {}}
/>
</div>
</div>
</div>
</div>
</div>
{/if}
static/manifest.json
deleted
100644 → 0
View file @
5558514f
{
"name"
:
"Open WebUI"
,
"short_name"
:
"Open WebUI"
,
"start_url"
:
"/"
,
"display"
:
"standalone"
,
"background_color"
:
"#343541"
,
"theme_color"
:
"#343541"
,
"orientation"
:
"portrait-primary"
,
"icons"
:
[
{
"src"
:
"/favicon.png"
,
"type"
:
"image/png"
,
"sizes"
:
"844x884"
}
]
}
Prev
1
2
3
Next
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