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
506a0613
Unverified
Commit
506a0613
authored
Apr 08, 2024
by
lainedfles
Committed by
GitHub
Apr 08, 2024
Browse files
Merge branch 'dev' into embedding-model-fix-and-manual-update
parents
ec530ac9
1a2971ae
Changes
60
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
556 additions
and
257 deletions
+556
-257
backend/static/fonts/NotoSansJP-Regular.ttf
backend/static/fonts/NotoSansJP-Regular.ttf
+0
-0
backend/static/fonts/NotoSansKR-Regular.ttf
backend/static/fonts/NotoSansKR-Regular.ttf
+0
-0
docker-compose.amdgpu.yaml
docker-compose.amdgpu.yaml
+8
-0
docker-compose.yaml
docker-compose.yaml
+2
-2
kubernetes/helm/templates/_helpers.tpl
kubernetes/helm/templates/_helpers.tpl
+1
-1
src/lib/apis/auths/index.ts
src/lib/apis/auths/index.ts
+8
-2
src/lib/apis/utils/index.ts
src/lib/apis/utils/index.ts
+26
-0
src/lib/components/chat/MessageInput.svelte
src/lib/components/chat/MessageInput.svelte
+11
-0
src/lib/components/chat/Messages.svelte
src/lib/components/chat/Messages.svelte
+14
-12
src/lib/components/chat/Messages/RateComment.svelte
src/lib/components/chat/Messages/RateComment.svelte
+117
-0
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+20
-2
src/lib/components/chat/Settings/Account.svelte
src/lib/components/chat/Settings/Account.svelte
+247
-190
src/lib/components/chat/Settings/General.svelte
src/lib/components/chat/Settings/General.svelte
+1
-1
src/lib/components/common/Modal.svelte
src/lib/components/common/Modal.svelte
+11
-0
src/lib/components/layout/Navbar/Menu.svelte
src/lib/components/layout/Navbar/Menu.svelte
+20
-43
src/lib/i18n/locales/bg-BG/translation.json
src/lib/i18n/locales/bg-BG/translation.json
+1
-1
src/lib/i18n/locales/ca-ES/translation.json
src/lib/i18n/locales/ca-ES/translation.json
+1
-1
src/lib/i18n/locales/de-DE/translation.json
src/lib/i18n/locales/de-DE/translation.json
+1
-1
src/lib/i18n/locales/en-GB/translation.json
src/lib/i18n/locales/en-GB/translation.json
+64
-0
src/lib/i18n/locales/en-US/translation.json
src/lib/i18n/locales/en-US/translation.json
+3
-1
No files found.
backend/static/fonts/NotoSansJP-Regular.ttf
0 → 100644
View file @
506a0613
File added
backend/static/fonts/NotoSansKR-Regular.ttf
0 → 100644
View file @
506a0613
File added
docker-compose.amdgpu.yaml
0 → 100644
View file @
506a0613
services
:
ollama
:
devices
:
-
/dev/kfd:/dev/kfd
-
/dev/dri:/dev/dri
image
:
ollama/ollama:${OLLAMA_DOCKER_TAG-rocm}
environment
:
-
'
HSA_OVERRIDE_GFX_VERSION=${HSA_OVERRIDE_GFX_VERSION-11.0.0}'
\ No newline at end of file
docker-compose.yaml
View file @
506a0613
...
@@ -8,7 +8,7 @@ services:
...
@@ -8,7 +8,7 @@ services:
pull_policy
:
always
pull_policy
:
always
tty
:
true
tty
:
true
restart
:
unless-stopped
restart
:
unless-stopped
image
:
ollama/ollama:latest
image
:
ollama/ollama:
${OLLAMA_DOCKER_TAG-
latest
}
open-webui
:
open-webui
:
build
:
build
:
...
@@ -16,7 +16,7 @@ services:
...
@@ -16,7 +16,7 @@ services:
args
:
args
:
OLLAMA_BASE_URL
:
'
/ollama'
OLLAMA_BASE_URL
:
'
/ollama'
dockerfile
:
Dockerfile
dockerfile
:
Dockerfile
image
:
ghcr.io/open-webui/open-webui:main
image
:
ghcr.io/open-webui/open-webui:
${WEBUI_DOCKER_TAG-
main
}
container_name
:
open-webui
container_name
:
open-webui
volumes
:
volumes
:
-
open-webui:/app/backend/data
-
open-webui:/app/backend/data
...
...
kubernetes/helm/templates/_helpers.tpl
View file @
506a0613
...
@@ -7,7 +7,7 @@ ollama
...
@@ -7,7 +7,7 @@ ollama
{{- end -}}
{{- end -}}
{{- define "ollama.url" -}}
{{- define "ollama.url" -}}
{{- printf "http://%s.%s.svc.cluster.local:%d/
api
" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.service.port | int) }}
{{- printf "http://%s.%s.svc.cluster.local:%d/" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.service.port | int) }}
{{- end }}
{{- end }}
{{- define "chart.name" -}}
{{- define "chart.name" -}}
...
...
src/lib/apis/auths/index.ts
View file @
506a0613
...
@@ -58,7 +58,12 @@ export const userSignIn = async (email: string, password: string) => {
...
@@ -58,7 +58,12 @@ export const userSignIn = async (email: string, password: string) => {
return
res
;
return
res
;
};
};
export
const
userSignUp
=
async
(
name
:
string
,
email
:
string
,
password
:
string
)
=>
{
export
const
userSignUp
=
async
(
name
:
string
,
email
:
string
,
password
:
string
,
profile_image_url
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/auths/signup`
,
{
const
res
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/auths/signup`
,
{
...
@@ -69,7 +74,8 @@ export const userSignUp = async (name: string, email: string, password: string)
...
@@ -69,7 +74,8 @@ export const userSignUp = async (name: string, email: string, password: string)
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
name
:
name
,
name
:
name
,
email
:
email
,
email
:
email
,
password
:
password
password
:
password
,
profile_image_url
:
profile_image_url
})
})
})
})
.
then
(
async
(
res
)
=>
{
.
then
(
async
(
res
)
=>
{
...
...
src/lib/apis/utils/index.ts
View file @
506a0613
...
@@ -22,6 +22,32 @@ export const getGravatarUrl = async (email: string) => {
...
@@ -22,6 +22,32 @@ export const getGravatarUrl = async (email: string) => {
return
res
;
return
res
;
};
};
export
const
downloadChatAsPDF
=
async
(
chat
:
object
)
=>
{
let
error
=
null
;
const
blob
=
await
fetch
(
`
${
WEBUI_API_BASE_URL
}
/utils/pdf`
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
({
title
:
chat
.
title
,
messages
:
chat
.
messages
})
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
blob
();
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
error
=
err
;
return
null
;
});
return
blob
;
};
export
const
getHTMLFromMarkdown
=
async
(
md
:
string
)
=>
{
export
const
getHTMLFromMarkdown
=
async
(
md
:
string
)
=>
{
let
error
=
null
;
let
error
=
null
;
...
...
src/lib/components/chat/MessageInput.svelte
View file @
506a0613
...
@@ -295,6 +295,13 @@
...
@@ -295,6 +295,13 @@
const dropZone = document.querySelector('body');
const dropZone = document.querySelector('body');
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
console.log('Escape');
dragged = false;
}
};
const onDragOver = (e) => {
const onDragOver = (e) => {
e.preventDefault();
e.preventDefault();
dragged = true;
dragged = true;
...
@@ -350,11 +357,15 @@
...
@@ -350,11 +357,15 @@
dragged = false;
dragged = false;
};
};
window.addEventListener('keydown', handleKeyDown);
dropZone?.addEventListener('dragover', onDragOver);
dropZone?.addEventListener('dragover', onDragOver);
dropZone?.addEventListener('drop', onDrop);
dropZone?.addEventListener('drop', onDrop);
dropZone?.addEventListener('dragleave', onDragLeave);
dropZone?.addEventListener('dragleave', onDragLeave);
return () => {
return () => {
window.removeEventListener('keydown', handleKeyDown);
dropZone?.removeEventListener('dragover', onDragOver);
dropZone?.removeEventListener('dragover', onDragOver);
dropZone?.removeEventListener('drop', onDrop);
dropZone?.removeEventListener('drop', onDrop);
dropZone?.removeEventListener('dragleave', onDragLeave);
dropZone?.removeEventListener('dragleave', onDragLeave);
...
...
src/lib/components/chat/Messages.svelte
View file @
506a0613
...
@@ -107,12 +107,8 @@
...
@@ -107,12 +107,8 @@
await sendPrompt(userPrompt, userMessageId, chatId);
await sendPrompt(userPrompt, userMessageId, chatId);
};
};
const confirmEditResponseMessage = async (messageId, content) => {
const updateChatMessages = async () => {
history.messages[messageId].originalContent = history.messages[messageId].content;
history.messages[messageId].content = content;
await tick();
await tick();
await updateChatById(localStorage.token, chatId, {
await updateChatById(localStorage.token, chatId, {
messages: messages,
messages: messages,
history: history
history: history
...
@@ -121,15 +117,20 @@
...
@@ -121,15 +117,20 @@
await chats.set(await getChatList(localStorage.token));
await chats.set(await getChatList(localStorage.token));
};
};
const confirmEditResponseMessage = async (messageId, content) => {
history.messages[messageId].originalContent = history.messages[messageId].content;
history.messages[messageId].content = content;
await updateChatMessages();
};
const rateMessage = async (messageId, rating) => {
const rateMessage = async (messageId, rating) => {
history.messages[messageId].rating = rating;
history.messages[messageId].annotation = {
await tick();
...history.messages[messageId].annotation,
await updateChatById(localStorage.token, chatId, {
rating: rating
messages: messages,
};
history: history
});
await
chats.set(await getChatList(localStorage.token)
);
await
updateChatMessages(
);
};
};
const showPreviousMessage = async (message) => {
const showPreviousMessage = async (message) => {
...
@@ -338,6 +339,7 @@
...
@@ -338,6 +339,7 @@
siblings={history.messages[message.parentId]?.childrenIds ?? []}
siblings={history.messages[message.parentId]?.childrenIds ?? []}
isLastMessage={messageIdx + 1 === messages.length}
isLastMessage={messageIdx + 1 === messages.length}
{readOnly}
{readOnly}
{updateChatMessages}
{confirmEditResponseMessage}
{confirmEditResponseMessage}
{showPreviousMessage}
{showPreviousMessage}
{showNextMessage}
{showNextMessage}
...
...
src/lib/components/chat/Messages/RateComment.svelte
0 → 100644
View file @
506a0613
<script lang="ts">
import { toast } from 'svelte-sonner';
import { createEventDispatcher, onMount } from 'svelte';
const dispatch = createEventDispatcher();
export let show = false;
export let message;
const LIKE_REASONS = [
`Accurate information`,
`Followed instructions perfectly`,
`Showcased creativity`,
`Positive attitude`,
`Attention to detail`,
`Thorough explanation`,
`Other`
];
const DISLIKE_REASONS = [
`Don't like the style`,
`Not factually correct`,
`Didn't fully follow instructions`,
`Refused when it shouldn't have`,
`Being Lazy`,
`Other`
];
let reasons = [];
let selectedReason = null;
let comment = '';
$: if (message.annotation.rating === 1) {
reasons = LIKE_REASONS;
} else if (message.annotation.rating === -1) {
reasons = DISLIKE_REASONS;
}
onMount(() => {
selectedReason = message.annotation.reason;
comment = message.annotation.comment;
});
const submitHandler = () => {
console.log('submitHandler');
message.annotation.reason = selectedReason;
message.annotation.comment = comment;
dispatch('submit');
toast.success('Thanks for your feedback!');
show = false;
};
</script>
<div class=" my-2.5 rounded-xl px-4 py-3 border dark:border-gray-850">
<div class="flex justify-between items-center">
<div class=" text-sm">Tell us more:</div>
<button
on:click={() => {
show = false;
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="size-4"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div>
{#if reasons.length > 0}
<div class="flex flex-wrap gap-2 text-sm mt-2.5">
{#each reasons as reason}
<button
class="px-3.5 py-1 border dark:border-gray-850 dark:hover:bg-gray-850 {selectedReason ===
reason
? 'dark:bg-gray-800'
: ''} transition rounded-lg"
on:click={() => {
selectedReason = reason;
}}
>
{reason}
</button>
{/each}
</div>
{/if}
<div class="mt-2">
<textarea
bind:value={comment}
class="w-full text-sm px-1 py-2 bg-transparent outline-none resize-none rounded-xl"
placeholder="Feel free to add specific details"
rows="2"
/>
</div>
<div class="mt-2 flex justify-end">
<button
class=" bg-emerald-700 text-white text-sm font-medium rounded-lg px-3.5 py-1.5"
on:click={() => {
submitHandler();
}}
>
Submit
</button>
</div>
</div>
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
506a0613
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
import Image from '$lib/components/common/Image.svelte';
import Image from '$lib/components/common/Image.svelte';
import { WEBUI_BASE_URL } from '$lib/constants';
import { WEBUI_BASE_URL } from '$lib/constants';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import RateComment from './RateComment.svelte';
export let modelfiles = [];
export let modelfiles = [];
export let message;
export let message;
...
@@ -39,6 +40,7 @@
...
@@ -39,6 +40,7 @@
export let readOnly = false;
export let readOnly = false;
export let updateChatMessages: Function;
export let confirmEditResponseMessage: Function;
export let confirmEditResponseMessage: Function;
export let showPreviousMessage: Function;
export let showPreviousMessage: Function;
export let showNextMessage: Function;
export let showNextMessage: Function;
...
@@ -60,6 +62,8 @@
...
@@ -60,6 +62,8 @@
let loadingSpeech = false;
let loadingSpeech = false;
let generatingImage = false;
let generatingImage = false;
let showRateComment = false;
$: tokens = marked.lexer(sanitizeResponseContent(message.content));
$: tokens = marked.lexer(sanitizeResponseContent(message.content));
const renderer = new marked.Renderer();
const renderer = new marked.Renderer();
...
@@ -536,11 +540,13 @@
...
@@ -536,11 +540,13 @@
<button
<button
class="{isLastMessage
class="{isLastMessage
? 'visible'
? 'visible'
: 'invisible group-hover:visible'} p-1 rounded {message.rating === 1
: 'invisible group-hover:visible'} p-1 rounded {message?.annotation
?.rating === 1
? 'bg-gray-100 dark:bg-gray-800'
? 'bg-gray-100 dark:bg-gray-800'
: ''} dark:hover:text-white hover:text-black transition"
: ''} dark:hover:text-white hover:text-black transition"
on:click={() => {
on:click={() => {
rateMessage(message.id, 1);
rateMessage(message.id, 1);
showRateComment = true;
}}
}}
>
>
<svg
<svg
...
@@ -563,11 +569,13 @@
...
@@ -563,11 +569,13 @@
<button
<button
class="{isLastMessage
class="{isLastMessage
? 'visible'
? 'visible'
: 'invisible group-hover:visible'} p-1 rounded {message.rating === -1
: 'invisible group-hover:visible'} p-1 rounded {message?.annotation
?.rating === -1
? 'bg-gray-100 dark:bg-gray-800'
? 'bg-gray-100 dark:bg-gray-800'
: ''} dark:hover:text-white hover:text-black transition"
: ''} dark:hover:text-white hover:text-black transition"
on:click={() => {
on:click={() => {
rateMessage(message.id, -1);
rateMessage(message.id, -1);
showRateComment = true;
}}
}}
>
>
<svg
<svg
...
@@ -824,6 +832,16 @@
...
@@ -824,6 +832,16 @@
{/if}
{/if}
</div>
</div>
{/if}
{/if}
{#if showRateComment}
<RateComment
bind:show={showRateComment}
bind:message
on:submit={() => {
updateChatMessages();
}}
/>
{/if}
</div>
</div>
{/if}
{/if}
</div>
</div>
...
...
src/lib/components/chat/Settings/Account.svelte
View file @
506a0613
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
import UpdatePassword from './Account/UpdatePassword.svelte';
import UpdatePassword from './Account/UpdatePassword.svelte';
import { getGravatarUrl } from '$lib/apis/utils';
import { getGravatarUrl } from '$lib/apis/utils';
import { generateInitialsImage, canvasPixelTest } from '$lib/utils';
import { copyToClipboard } from '$lib/utils';
import { copyToClipboard } from '$lib/utils';
import Plus from '$lib/components/icons/Plus.svelte';
import Plus from '$lib/components/icons/Plus.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
...
@@ -18,6 +19,8 @@
...
@@ -18,6 +19,8 @@
let profileImageUrl = '';
let profileImageUrl = '';
let name = '';
let name = '';
let showAPIKeys = false;
let showJWTToken = false;
let showJWTToken = false;
let JWTTokenCopied = false;
let JWTTokenCopied = false;
...
@@ -28,6 +31,12 @@
...
@@ -28,6 +31,12 @@
let profileImageInputElement: HTMLInputElement;
let profileImageInputElement: HTMLInputElement;
const submitHandler = async () => {
const submitHandler = async () => {
if (name !== $user.name) {
if (profileImageUrl === generateInitialsImage($user.name) || profileImageUrl === '') {
profileImageUrl = generateInitialsImage(name);
}
}
const updatedUser = await updateUserProfile(localStorage.token, name, profileImageUrl).catch(
const updatedUser = await updateUserProfile(localStorage.token, name, profileImageUrl).catch(
(error) => {
(error) => {
toast.error(error);
toast.error(error);
...
@@ -125,11 +134,12 @@
...
@@ -125,11 +134,12 @@
}}
}}
/>
/>
<div class=" mb-2.5 text-sm font-medium">{$i18n.t('Profile')}</div>
<div class="space-y-1">
<!-- <div class=" text-sm font-medium">{$i18n.t('Account')}</div> -->
<div class="flex space-x-5">
<div class="flex space-x-5">
<div class="flex flex-col">
<div class="flex flex-col">
<div class="self-center">
<div class="self-center
mt-2
">
<button
<button
class="relative rounded-full dark:bg-gray-700"
class="relative rounded-full dark:bg-gray-700"
type="button"
type="button"
...
@@ -138,9 +148,9 @@
...
@@ -138,9 +148,9 @@
}}
}}
>
>
<img
<img
src={profileImageUrl !== '' ? profileImageUrl :
'/user.png'
}
src={profileImageUrl !== '' ? profileImageUrl :
generateInitialsImage(name)
}
alt="profile"
alt="profile"
class=" rounded-full
w-16 h
-16 object-cover"
class=" rounded-full
size
-16 object-cover"
/>
/>
<div
<div
...
@@ -161,23 +171,56 @@
...
@@ -161,23 +171,56 @@
</div>
</div>
</button>
</button>
</div>
</div>
</div>
<div class="flex-1 flex flex-col self-center gap-0.5">
<div class=" mb-0.5 text-sm font-medium">{$i18n.t('Profile Image')}</div>
<div>
<button
class=" text-xs text-center text-gray-800 dark:text-gray-400 rounded-full px-4 py-0.5 bg-gray-100 dark:bg-gray-850"
on:click={async () => {
if (canvasPixelTest()) {
profileImageUrl = generateInitialsImage(name);
} else {
toast.info(
$i18n.t(
'Fingerprint spoofing detected: Unable to use initials as avatar. Defaulting to default profile image.'
),
{
duration: 1000 * 10
}
);
}
}}>{$i18n.t('Use Initials')}</button
>
<button
<button
class=" text-xs text-
gray-60
0"
class=" text-xs text-
center text-gray-800 dark:text-gray-400 rounded-full px-4 py-0.5 bg-gray-100 dark:bg-gray-85
0"
on:click={async () => {
on:click={async () => {
const url = await getGravatarUrl($user.email);
const url = await getGravatarUrl($user.email);
profileImageUrl = url;
profileImageUrl = url;
}}>{$i18n.t('Use Gravatar')}</button
}}>{$i18n.t('Use Gravatar')}</button
>
>
<button
class=" text-xs text-center text-gray-800 dark:text-gray-400 rounded-lg px-2 py-1"
on:click={async () => {
profileImageUrl = '/user.png';
}}>{$i18n.t('Remove')}</button
>
</div>
</div>
</div>
</div>
<div class="
flex-1
">
<div class="
pt-0.5
">
<div class="flex flex-col w-full">
<div class="flex flex-col w-full">
<div class=" mb-1 text-xs
text-gray-500
">{$i18n.t('Name')}</div>
<div class=" mb-1 text-xs
font-medium
">{$i18n.t('Name')}</div>
<div class="flex-1">
<div class="flex-1">
<input
<input
class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-8
0
0 outline-none"
class="w-full rounded
-lg
py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-8
5
0 outline-none"
type="text"
type="text"
bind:value={name}
bind:value={name}
required
required
...
@@ -187,11 +230,24 @@
...
@@ -187,11 +230,24 @@
</div>
</div>
</div>
</div>
<
hr
class="
dark:border-gray-700 my-4" /
>
<
div
class="
py-0.5"
>
<UpdatePassword />
<UpdatePassword />
</div>
<hr class=" dark:border-gray-700 my-4" />
<hr class=" dark:border-gray-700 my-4" />
<div class="flex justify-between items-center text-sm">
<div class=" font-medium">{$i18n.t('API keys')}</div>
<button
class=" text-xs font-medium text-gray-500"
type="button"
on:click={() => {
showAPIKeys = !showAPIKeys;
}}>{showAPIKeys ? $i18n.t('Hide') : $i18n.t('Show')}</button
>
</div>
{#if showAPIKeys}
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-4">
<div class="justify-between w-full">
<div class="justify-between w-full">
<div class="flex justify-between w-full">
<div class="flex justify-between w-full">
...
@@ -201,14 +257,14 @@
...
@@ -201,14 +257,14 @@
<div class="flex mt-2">
<div class="flex mt-2">
<div class="flex w-full">
<div class="flex w-full">
<input
<input
class="w-full rounded-l-lg py-1.5 pl-4 text-sm bg-white dark:text-gray-300 dark:bg-gray-8
0
0 outline-none"
class="w-full rounded-l-lg py-1.5 pl-4 text-sm bg-white dark:text-gray-300 dark:bg-gray-8
5
0 outline-none"
type={showJWTToken ? 'text' : 'password'}
type={showJWTToken ? 'text' : 'password'}
value={localStorage.token}
value={localStorage.token}
disabled
disabled
/>
/>
<button
<button
class="px-2 transition rounded-r-lg bg-white dark:bg-gray-8
0
0"
class="px-2 transition rounded-r-lg bg-white dark:bg-gray-8
5
0"
on:click={() => {
on:click={() => {
showJWTToken = !showJWTToken;
showJWTToken = !showJWTToken;
}}
}}
...
@@ -248,7 +304,7 @@
...
@@ -248,7 +304,7 @@
</div>
</div>
<button
<button
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-8
0
0 transition rounded-lg"
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-8
5
0 transition rounded-lg"
on:click={() => {
on:click={() => {
copyToClipboard(localStorage.token);
copyToClipboard(localStorage.token);
JWTTokenCopied = true;
JWTTokenCopied = true;
...
@@ -301,14 +357,14 @@
...
@@ -301,14 +357,14 @@
{#if APIKey}
{#if APIKey}
<div class="flex w-full">
<div class="flex w-full">
<input
<input
class="w-full rounded-l-lg py-1.5 pl-4 text-sm bg-white dark:text-gray-300 dark:bg-gray-8
0
0 outline-none"
class="w-full rounded-l-lg py-1.5 pl-4 text-sm bg-white dark:text-gray-300 dark:bg-gray-8
5
0 outline-none"
type={showAPIKey ? 'text' : 'password'}
type={showAPIKey ? 'text' : 'password'}
value={APIKey}
value={APIKey}
disabled
disabled
/>
/>
<button
<button
class="px-2 transition rounded-r-lg bg-white dark:bg-gray-8
0
0"
class="px-2 transition rounded-r-lg bg-white dark:bg-gray-8
5
0"
on:click={() => {
on:click={() => {
showAPIKey = !showAPIKey;
showAPIKey = !showAPIKey;
}}
}}
...
@@ -348,7 +404,7 @@
...
@@ -348,7 +404,7 @@
</div>
</div>
<button
<button
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-8
0
0 transition rounded-lg"
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-8
5
0 transition rounded-lg"
on:click={() => {
on:click={() => {
copyToClipboard(APIKey);
copyToClipboard(APIKey);
APIKeyCopied = true;
APIKeyCopied = true;
...
@@ -393,7 +449,7 @@
...
@@ -393,7 +449,7 @@
<Tooltip content="Create new key">
<Tooltip content="Create new key">
<button
<button
class=" px-1.5 py-1 dark:hover:bg-gray-8
0
0transition rounded-lg"
class=" px-1.5 py-1 dark:hover:bg-gray-8
5
0transition rounded-lg"
on:click={() => {
on:click={() => {
createAPIKeyHandler();
createAPIKeyHandler();
}}
}}
...
@@ -416,7 +472,7 @@
...
@@ -416,7 +472,7 @@
</Tooltip>
</Tooltip>
{:else}
{:else}
<button
<button
class="flex gap-1.5 items-center font-medium px-3.5 py-1.5 rounded-lg bg-gray-100/70 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-8
0
0 transition"
class="flex gap-1.5 items-center font-medium px-3.5 py-1.5 rounded-lg bg-gray-100/70 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-8
5
0 transition"
on:click={() => {
on:click={() => {
createAPIKeyHandler();
createAPIKeyHandler();
}}
}}
...
@@ -429,6 +485,7 @@
...
@@ -429,6 +485,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
{/if}
</div>
</div>
<div class="flex justify-end pt-3 text-sm font-medium">
<div class="flex justify-end pt-3 text-sm font-medium">
...
...
src/lib/components/chat/Settings/General.svelte
View file @
506a0613
...
@@ -185,7 +185,7 @@
...
@@ -185,7 +185,7 @@
<div>
<div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs font-medium">{$i18n.t('
Desktop
Notifications')}</div>
<div class=" self-center text-xs font-medium">{$i18n.t('Notifications')}</div>
<button
<button
class="p-1 px-3 text-xs flex rounded transition"
class="p-1 px-3 text-xs flex rounded transition"
...
...
src/lib/components/common/Modal.svelte
View file @
506a0613
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
export let show = true;
export let show = true;
export let size = 'md';
export let size = 'md';
let modalElement = null;
let mounted = false;
let mounted = false;
const sizeToWidth = (size) => {
const sizeToWidth = (size) => {
...
@@ -19,14 +20,23 @@
...
@@ -19,14 +20,23 @@
}
}
};
};
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
console.log('Escape');
show = false;
}
};
onMount(() => {
onMount(() => {
mounted = true;
mounted = true;
});
});
$: if (mounted) {
$: if (mounted) {
if (show) {
if (show) {
window.addEventListener('keydown', handleKeyDown);
document.body.style.overflow = 'hidden';
document.body.style.overflow = 'hidden';
} else {
} else {
window.removeEventListener('keydown', handleKeyDown);
document.body.style.overflow = 'unset';
document.body.style.overflow = 'unset';
}
}
}
}
...
@@ -36,6 +46,7 @@
...
@@ -36,6 +46,7 @@
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
<div
bind:this={modalElement}
class=" fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full min-h-screen h-screen flex justify-center z-50 overflow-hidden overscroll-contain"
class=" fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full min-h-screen h-screen flex justify-center z-50 overflow-hidden overscroll-contain"
in:fade={{ duration: 10 }}
in:fade={{ duration: 10 }}
on:click={() => {
on:click={() => {
...
...
src/lib/components/layout/Navbar/Menu.svelte
View file @
506a0613
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
import Dropdown from '$lib/components/common/Dropdown.svelte';
import Dropdown from '$lib/components/common/Dropdown.svelte';
import Tags from '$lib/components/common/Tags.svelte';
import Tags from '$lib/components/common/Tags.svelte';
import { WEBUI_BASE_URL } from '$lib/constants';
import { downloadChatAsPDF } from '$lib/apis/utils';
export let shareEnabled: boolean = false;
export let shareEnabled: boolean = false;
export let shareHandler: Function;
export let shareHandler: Function;
...
@@ -25,7 +27,7 @@
...
@@ -25,7 +27,7 @@
export let onClose: Function = () => {};
export let onClose: Function = () => {};
const download
ChatAs
Txt = async () => {
const downloadTxt = async () => {
const _chat = chat.chat;
const _chat = chat.chat;
console.log('download', chat);
console.log('download', chat);
...
@@ -40,54 +42,29 @@
...
@@ -40,54 +42,29 @@
saveAs(blob, `chat-${_chat.title}.txt`);
saveAs(blob, `chat-${_chat.title}.txt`);
};
};
const download
ChatAs
Pdf = async () => {
const downloadPdf = async () => {
const _chat = chat.chat;
const _chat = chat.chat;
console.log('download', chat);
console.log('download', chat);
const
doc = new jsPDF(
);
const
blob = await downloadChatAsPDF(_chat
);
// Initialize y-coordinate for text placement
// Create a URL for the blob
let yPos = 10;
const url = window.URL.createObjectURL(blob);
const pageHeight = doc.internal.pageSize.height;
// Function to check if new text exceeds the current page height
// Create a link element to trigger the download
function checkAndAddNewPage() {
const a = document.createElement('a');
if (yPos > pageHeight - 10) {
a.href = url;
doc.addPage();
a.download = `chat-${_chat.title}.pdf`;
yPos = 10; // Reset yPos for the new page
}
}
// Function to add text with specific style
function addStyledText(text, isTitle = false) {
// Set font style and size based on the parameters
doc.setFont('helvetica', isTitle ? 'bold' : 'normal');
doc.setFontSize(isTitle ? 12 : 10);
const textMargin = 7;
// Split text into lines to ensure it fits within the page width
const lines = doc.splitTextToSize(text, 180); // Adjust the width as needed
lines.forEach((line) => {
// Append the link to the body and click it programmatically
checkAndAddNewPage(); // Check if we need a new page before adding more text
document.body.appendChild(a);
doc.text(line, 10, yPos);
a.click();
yPos += textMargin; // Increment yPos for the next line
});
// Add extra space after a block of text
yPos += 2;
}
_chat.messages.forEach((message, i) => {
// Remove the link from the body
// Add user text in bold
document.body.removeChild(a);
doc.setFont('helvetica', 'normal', 'bold');
addStyledText(message.role.toUpperCase(), { isTitle: true });
addStyledText(message.content);
});
doc.save(`chat-${_chat.title}.pdf`);
// Revoke the URL to release memory
window.URL.revokeObjectURL(url);
};
};
</script>
</script>
...
@@ -193,7 +170,7 @@
...
@@ -193,7 +170,7 @@
<DropdownMenu.Item
<DropdownMenu.Item
class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer dark:hover:bg-gray-850 rounded-md"
class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer dark:hover:bg-gray-850 rounded-md"
on:click={() => {
on:click={() => {
download
ChatAs
Txt();
downloadTxt();
}}
}}
>
>
<div class="flex items-center line-clamp-1">Plain text (.txt)</div>
<div class="flex items-center line-clamp-1">Plain text (.txt)</div>
...
@@ -202,7 +179,7 @@
...
@@ -202,7 +179,7 @@
<DropdownMenu.Item
<DropdownMenu.Item
class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer dark:hover:bg-gray-850 rounded-md"
class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer dark:hover:bg-gray-850 rounded-md"
on:click={() => {
on:click={() => {
download
ChatAs
Pdf();
downloadPdf();
}}
}}
>
>
<div class="flex items-center line-clamp-1">PDF document (.pdf)</div>
<div class="flex items-center line-clamp-1">PDF document (.pdf)</div>
...
...
src/lib/i18n/locales/bg-BG/translation.json
View file @
506a0613
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
"Deleted {{deleteModelTag}}"
:
"Изтрито {{deleteModelTag}}"
,
"Deleted {{deleteModelTag}}"
:
"Изтрито {{deleteModelTag}}"
,
"Deleted {tagName}"
:
"Изтрито {tagName}"
,
"Deleted {tagName}"
:
"Изтрито {tagName}"
,
"Description"
:
"Описание"
,
"Description"
:
"Описание"
,
"
Desktop
Notifications"
:
"Десктоп Известия"
,
"Notifications"
:
"Десктоп Известия"
,
"Disabled"
:
"Деактивиран"
,
"Disabled"
:
"Деактивиран"
,
"Discover a modelfile"
:
"Откриване на модфайл"
,
"Discover a modelfile"
:
"Откриване на модфайл"
,
"Discover a prompt"
:
"Откриване на промпт"
,
"Discover a prompt"
:
"Откриване на промпт"
,
...
...
src/lib/i18n/locales/ca-ES/translation.json
View file @
506a0613
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
"Deleted {{deleteModelTag}}"
:
"Esborrat {{deleteModelTag}}"
,
"Deleted {{deleteModelTag}}"
:
"Esborrat {{deleteModelTag}}"
,
"Deleted {tagName}"
:
"Esborrat {tagName}"
,
"Deleted {tagName}"
:
"Esborrat {tagName}"
,
"Description"
:
"Descripció"
,
"Description"
:
"Descripció"
,
"
Desktop
Notifications"
:
"Notificacions d'Escriptori"
,
"Notifications"
:
"Notificacions d'Escriptori"
,
"Disabled"
:
"Desactivat"
,
"Disabled"
:
"Desactivat"
,
"Discover a modelfile"
:
"Descobreix un fitxer de model"
,
"Discover a modelfile"
:
"Descobreix un fitxer de model"
,
"Discover a prompt"
:
"Descobreix un prompt"
,
"Discover a prompt"
:
"Descobreix un prompt"
,
...
...
src/lib/i18n/locales/de-DE/translation.json
View file @
506a0613
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
"Deleted {{deleteModelTag}}"
:
"{{deleteModelTag}} gelöscht"
,
"Deleted {{deleteModelTag}}"
:
"{{deleteModelTag}} gelöscht"
,
"Deleted {tagName}"
:
"{tagName} gelöscht"
,
"Deleted {tagName}"
:
"{tagName} gelöscht"
,
"Description"
:
"Beschreibung"
,
"Description"
:
"Beschreibung"
,
"
Desktop
Notifications"
:
"Desktop-Benachrichtigungen"
,
"Notifications"
:
"Desktop-Benachrichtigungen"
,
"Disabled"
:
"Deaktiviert"
,
"Disabled"
:
"Deaktiviert"
,
"Discover a modelfile"
:
"Eine Modelfiles entdecken"
,
"Discover a modelfile"
:
"Eine Modelfiles entdecken"
,
"Discover a prompt"
:
"Einen Prompt entdecken"
,
"Discover a prompt"
:
"Einen Prompt entdecken"
,
...
...
src/lib/i18n/locales/en-GB/translation.json
0 → 100644
View file @
506a0613
{
"analyze"
:
"analyse"
,
"analyzed"
:
"analysed"
,
"analyzes"
:
"analyses"
,
"apologize"
:
"apologise"
,
"apologized"
:
"apologised"
,
"apologizes"
:
"apologises"
,
"apologizing"
:
"apologising"
,
"canceled"
:
"cancelled"
,
"canceling"
:
"cancelling"
,
"capitalize"
:
"capitalise"
,
"capitalized"
:
"capitalised"
,
"capitalizes"
:
"capitalises"
,
"center"
:
"centre"
,
"centered"
:
"centred"
,
"color"
:
"colour"
,
"colorize"
:
"colourise"
,
"customize"
:
"customise"
,
"customizes"
:
"customises"
,
"defense"
:
"defence"
,
"dialog"
:
"dialogue"
,
"emphasize"
:
"emphasise"
,
"emphasized"
:
"emphasised"
,
"emphasizes"
:
"emphasises"
,
"favor"
:
"favour"
,
"favorable"
:
"favourable"
,
"favorite"
:
"favourite"
,
"favoritism"
:
"favouritism"
,
"labor"
:
"labour"
,
"labored"
:
"laboured"
,
"laboring"
:
"labouring"
,
"maximize"
:
"maximise"
,
"maximizes"
:
"maximises"
,
"minimize"
:
"minimise"
,
"minimizes"
:
"minimises"
,
"neighbor"
:
"neighbour"
,
"neighborhood"
:
"neighbourhood"
,
"offense"
:
"offence"
,
"organize"
:
"organise"
,
"organizes"
:
"organises"
,
"personalize"
:
"personalise"
,
"personalizes"
:
"personalises"
,
"program"
:
"programme"
,
"programmed"
:
"programmed"
,
"programs"
:
"programmes"
,
"quantization"
:
"quantisation"
,
"quantize"
:
"quantise"
,
"randomize"
:
"randomise"
,
"randomizes"
:
"randomises"
,
"realize"
:
"realise"
,
"realizes"
:
"realises"
,
"recognize"
:
"recognise"
,
"recognizes"
:
"recognises"
,
"summarize"
:
"summarise"
,
"summarizes"
:
"summarises"
,
"theater"
:
"theatre"
,
"theaters"
:
"theatres"
,
"toward"
:
"towards"
,
"traveled"
:
"travelled"
,
"traveler"
:
"traveller"
,
"traveling"
:
"travelling"
,
"utilize"
:
"utilise"
,
"utilizes"
:
"utilises"
}
src/lib/i18n/locales/en-US/translation.json
View file @
506a0613
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
"Deleted {{deleteModelTag}}"
:
""
,
"Deleted {{deleteModelTag}}"
:
""
,
"Deleted {tagName}"
:
""
,
"Deleted {tagName}"
:
""
,
"Description"
:
""
,
"Description"
:
""
,
"
Desktop
Notifications"
:
""
,
"Notifications"
:
""
,
"Disabled"
:
""
,
"Disabled"
:
""
,
"Discover a modelfile"
:
""
,
"Discover a modelfile"
:
""
,
"Discover a prompt"
:
""
,
"Discover a prompt"
:
""
,
...
@@ -151,6 +151,7 @@
...
@@ -151,6 +151,7 @@
"Failed to read clipboard contents"
:
""
,
"Failed to read clipboard contents"
:
""
,
"File Mode"
:
""
,
"File Mode"
:
""
,
"File not found."
:
""
,
"File not found."
:
""
,
"Fingerprint spoofing detected: Unable to use initials as avatar. Defaulting to default profile image."
:
""
,
"Focus chat input"
:
""
,
"Focus chat input"
:
""
,
"Format your variables using square brackets like this:"
:
""
,
"Format your variables using square brackets like this:"
:
""
,
"From (Base Model)"
:
""
,
"From (Base Model)"
:
""
,
...
@@ -347,6 +348,7 @@
...
@@ -347,6 +348,7 @@
"URL Mode"
:
""
,
"URL Mode"
:
""
,
"Use '#' in the prompt input to load and select your documents."
:
""
,
"Use '#' in the prompt input to load and select your documents."
:
""
,
"Use Gravatar"
:
""
,
"Use Gravatar"
:
""
,
"Use Initials"
:
""
,
"user"
:
""
,
"user"
:
""
,
"User Permissions"
:
""
,
"User Permissions"
:
""
,
"Users"
:
""
,
"Users"
:
""
,
...
...
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