Skip to content

Commit

Permalink
Merge pull request open-webui#5711 from open-webui/dev
Browse files Browse the repository at this point in the history
0.3.30
  • Loading branch information
tjbck authored Sep 26, 2024
2 parents 82cda6e + be41994 commit 7b8f923
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 50 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.30] - 2024-09-26

### Fixed

- **🍞 Update Available Toast Dismissal**: Enhanced user experience by ensuring that once the update available notification is dismissed, it won't reappear for 24 hours.
- **📋 Ollama /embed Form Data**: Adjusted the integration inaccuracies in the /embed form data to ensure it perfectly matches with Ollama's specifications.
- **🔧 O1 Max Completion Tokens Issue**: Resolved compatibility issues with OpenAI's o1 models max_completion_tokens param to ensure smooth operation.
- **🔄 Pip Install Database Issue**: Fixed a critical issue where database changes during pip installations were reverting and not saving chat logs, now ensuring data persistence and reliability in chat operations.
- **🏷️ Chat Rename Tab Update**: Fixed the functionality to change the web browser's tab title simultaneously when a chat is renamed, keeping tab titles consistent.

## [0.3.29] - 2023-09-25

### Fixed
Expand Down
10 changes: 9 additions & 1 deletion backend/open_webui/apps/ollama/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,18 @@ class GenerateEmbeddingsForm(BaseModel):
keep_alive: Optional[Union[int, str]] = None


class GenerateEmbedForm(BaseModel):
model: str
input: str
truncate: Optional[bool]
options: Optional[dict] = None
keep_alive: Optional[Union[int, str]] = None


@app.post("/api/embed")
@app.post("/api/embed/{url_idx}")
async def generate_embeddings(
form_data: GenerateEmbeddingsForm,
form_data: GenerateEmbedForm,
url_idx: Optional[int] = None,
user=Depends(get_verified_user),
):
Expand Down
3 changes: 3 additions & 0 deletions backend/open_webui/apps/openai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ async def generate_chat_completion(
payload["max_tokens"] = payload["max_completion_tokens"]
del payload["max_completion_tokens"]
else:
if payload["model"].lower().startswith("o1-") and "max_tokens" in payload:
payload["max_completion_tokens"] = payload["max_tokens"]
del payload["max_tokens"]
if "max_tokens" in payload and "max_completion_tokens" in payload:
del payload["max_tokens"]

Expand Down
6 changes: 6 additions & 0 deletions backend/open_webui/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ def parse_section(section):
else:
shutil.copy2(item, dest)

# Zip the data directory
shutil.make_archive(DATA_DIR.parent / "open_webui_data", "zip", DATA_DIR)

# Remove the old data directory
shutil.rmtree(DATA_DIR)

DATA_DIR = Path(os.getenv("DATA_DIR", OPEN_WEBUI_DIR / "data"))


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "open-webui",
"version": "0.3.29",
"version": "0.3.30",
"private": true,
"scripts": {
"dev": "npm run pyodide:fetch && vite dev --host",
Expand Down
40 changes: 25 additions & 15 deletions src/lib/components/chat/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
currentChatPage,
temporaryChatEnabled,
mobile,
showOverview
showOverview,
chatTitle
} from '$lib/stores';
import {
convertMessagesToHistory,
Expand Down Expand Up @@ -102,7 +103,6 @@
let chat = null;
let tags = [];
let title = '';
let history = {
messages: {},
currentId: null
Expand Down Expand Up @@ -296,6 +296,8 @@
const chatInput = document.getElementById('chat-textarea');
chatInput?.focus();
chats.subscribe(() => {});
});
onDestroy(() => {
Expand All @@ -313,10 +315,11 @@
window.history.replaceState(history.state, '', `/`);
}
await chatId.set('');
autoScroll = true;
title = '';
await chatId.set('');
await chatTitle.set('');
history = {
messages: {},
currentId: null
Expand Down Expand Up @@ -398,7 +401,8 @@
(chatContent?.history ?? undefined) !== undefined
? chatContent.history
: convertMessagesToHistory(chatContent.messages);
title = chatContent.title;
chatTitle.set(chatContent.title);
const userSettings = await getUserSettings(localStorage.token);
Expand Down Expand Up @@ -1207,8 +1211,8 @@
const messages = createMessagesList(responseMessageId);
if (messages.length == 2 && messages.at(-1).content !== '' && selectedModels[0] === model.id) {
window.history.replaceState(history.state, '', `/c/${_chatId}`);
const _title = await generateChatTitle(userPrompt);
await setChatTitle(_chatId, _title);
const title = await generateChatTitle(userPrompt);
await setChatTitle(_chatId, title);
}
return _response;
Expand Down Expand Up @@ -1497,8 +1501,8 @@
const messages = createMessagesList(responseMessageId);
if (messages.length == 2 && selectedModels[0] === model.id) {
window.history.replaceState(history.state, '', `/c/${_chatId}`);
const _title = await generateChatTitle(userPrompt);
await setChatTitle(_chatId, _title);
const title = await generateChatTitle(userPrompt);
await setChatTitle(_chatId, title);
}
return _response;
Expand Down Expand Up @@ -1672,13 +1676,13 @@
}
};
const setChatTitle = async (_chatId, _title) => {
const setChatTitle = async (_chatId, title) => {
if (_chatId === $chatId) {
title = _title;
chatTitle.set(title);
}
if (!$temporaryChatEnabled) {
chat = await updateChatById(localStorage.token, _chatId, { title: _title });
chat = await updateChatById(localStorage.token, _chatId, { title: title });
currentChatPage.set(1);
await chats.set(await getChatList(localStorage.token, $currentChatPage));
Expand Down Expand Up @@ -1817,8 +1821,8 @@

<svelte:head>
<title>
{title
? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}`
{$chatTitle
? `${$chatTitle.length > 30 ? `${$chatTitle.slice(0, 30)}...` : $chatTitle} | ${$WEBUI_NAME}`
: `${$WEBUI_NAME}`}
</title>
</svelte:head>
Expand Down Expand Up @@ -1863,7 +1867,13 @@
/>
{/if}

<Navbar {chat} {title} bind:selectedModels shareEnabled={!!history.currentId} {initNewChat} />
<Navbar
{chat}
title={$chatTitle}
bind:selectedModels
shareEnabled={!!history.currentId}
{initNewChat}
/>

<PaneGroup direction="horizontal" class="w-full h-full">
<Pane defaultSize={50} class="h-full flex w-full relative">
Expand Down
20 changes: 16 additions & 4 deletions src/lib/components/layout/Sidebar/ChatItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
getChatListByTagName,
updateChatById
} from '$lib/apis/chats';
import { chatId, chats, mobile, pinnedChats, showSidebar, currentChatPage } from '$lib/stores';
import {
chatId,
chatTitle as _chatTitle,
chats,
mobile,
pinnedChats,
showSidebar,
currentChatPage
} from '$lib/stores';
import ChatMenu from './ChatMenu.svelte';
import ShareChatModal from '$lib/components/chat/ShareChatModal.svelte';
Expand All @@ -33,14 +41,18 @@
let chatTitle = chat.title;
const editChatTitle = async (id, _title) => {
if (_title === '') {
const editChatTitle = async (id, title) => {
if (title === '') {
toast.error($i18n.t('Title cannot be an empty string.'));
} else {
await updateChatById(localStorage.token, id, {
title: _title
title: title
});
if (id === $chatId) {
_chatTitle.set(title);
}
currentChatPage.set(1);
await chats.set(await getChatList(localStorage.token, $currentChatPage));
await pinnedChats.set(await getChatListByTagName(localStorage.token, 'pinned'));
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/layout/UpdateInfoToast.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</script>

<div
class="flex items-start bg-[--info-bg] border border-[--info-border] text-[--info-text] rounded-lg px-3.5 py-3 text-xs"
class="flex items-start bg-[#F1F8FE] dark:bg-[#020C1D] border border-[3371D5] dark:border-[#03113B] text-[#3371D5] dark:text-[#6795EC] rounded-lg px-3.5 py-3 text-xs max-w-80 pr-2 w-full shadow-lg"
>
<div class="flex-1 font-medium">
{$i18n.t(`A new version (v{{LATEST_VERSION}}) is now available.`, {
Expand All @@ -35,6 +35,7 @@
class=" hover:text-blue-900 dark:hover:text-blue-300 transition"
on:click={() => {
console.log('closeToast');
localStorage.setItem('dismissedUpdateToast', Date.now().toString());
dispatch('closeToast');
}}
>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const activeUserCount: Writable<null | number> = writable(null);
export const USAGE_POOL: Writable<null | string[]> = writable(null);

export const theme = writable('system');

export const chatId = writable('');
export const chatTitle = writable('');

export const chats = writable([]);
export const pinnedChats = writable([]);
Expand Down
35 changes: 22 additions & 13 deletions src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@
import { compareVersion } from '$lib/utils';
import UpdateInfoToast from '$lib/components/layout/UpdateInfoToast.svelte';
import { fade } from 'svelte/transition';
const i18n = getContext('i18n');
let loaded = false;
let DB = null;
let localDBChats = [];
let version;
const getModels = async () => {
return _getModels(localStorage.token);
};
Expand Down Expand Up @@ -195,39 +198,45 @@
temporaryChatEnabled.set(true);
}
// Check for version updates
if ($user.role === 'admin') {
checkForVersionUpdates();
}
// Check if the user has dismissed the update toast in the last 24 hours
if (localStorage.dismissedUpdateToast) {
const dismissedUpdateToast = new Date(Number(localStorage.dismissedUpdateToast));
const now = new Date();
if (now - dismissedUpdateToast > 24 * 60 * 60 * 1000) {
await checkForVersionUpdates();
}
} else {
await checkForVersionUpdates();
}
}
await tick();
}
loaded = true;
});
const checkForVersionUpdates = async () => {
const version = await getVersionUpdates(localStorage.token).catch((error) => {
version = await getVersionUpdates(localStorage.token).catch((error) => {
return {
current: WEBUI_VERSION,
latest: WEBUI_VERSION
};
});
if (compareVersion(version.latest, version.current)) {
toast.custom(UpdateInfoToast, {
duration: Number.POSITIVE_INFINITY,
position: 'bottom-right',
componentProps: {
version
}
});
}
};
</script>

<SettingsModal bind:show={$showSettings} />
<ChangelogModal bind:show={$showChangelog} />

{#if version && compareVersion(version.latest, version.current)}
<div class=" absolute bottom-8 right-8 z-50" in:fade={{ duration: 100 }}>
<UpdateInfoToast {version} />
</div>
{/if}

<div class="app relative">
<div
class=" text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-900 h-screen max-h-[100dvh] overflow-auto flex flex-row"
Expand Down
Loading

0 comments on commit 7b8f923

Please sign in to comment.