diff --git a/CHANGELOG.md b/CHANGELOG.md index fb56e4c6f..36fbf58c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ 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.29] - 2023-09-25 + +### Fixed + +- **🔧 KaTeX Rendering Improvement**: Resolved specific corner cases in KaTeX rendering to enhance the display of complex mathematical notation. +- **📞 'Call' URL Parameter Fix**: Corrected functionality for 'call' URL search parameter ensuring reliable activation of voice calls through URL triggers. +- **🔄 Configuration Reset Fix**: Fixed the RESET_CONFIG_ON_START to ensure settings revert to default correctly upon each startup, improving reliability in configuration management. +- **🌍 Filter Outlet Hook Fix**: Addressed issues in the filter outlet hook, ensuring all filter functions operate as intended. + ## [0.3.28] - 2024-09-24 ### Fixed diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 86d8a47a3..f531a8728 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -87,6 +87,12 @@ def save_to_db(data): db.commit() +def reset_config(): + with get_db() as db: + db.query(Config).delete() + db.commit() + + # When initializing, check if config.json exists and migrate it to the database if os.path.exists(f"{DATA_DIR}/config.json"): data = load_json_config() diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 4536f91fd..bc4d94ee4 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -234,18 +234,6 @@ if FROM_INIT_PY: ).resolve() -RESET_CONFIG_ON_START = ( - os.environ.get("RESET_CONFIG_ON_START", "False").lower() == "true" -) - -if RESET_CONFIG_ON_START: - try: - os.remove(f"{DATA_DIR}/config.json") - with open(f"{DATA_DIR}/config.json", "w") as f: - f.write("{}") - except Exception: - pass - #################################### # Database #################################### @@ -265,6 +253,10 @@ if "postgres://" in DATABASE_URL: DATABASE_URL = DATABASE_URL.replace("postgres://", "postgresql://") +RESET_CONFIG_ON_START = ( + os.environ.get("RESET_CONFIG_ON_START", "False").lower() == "true" +) + #################################### # WEBUI_AUTH (Required for security) #################################### diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index d190b916e..4af48906b 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -79,6 +79,7 @@ from open_webui.config import ( WEBUI_NAME, AppConfig, run_migrations, + reset_config, ) from open_webui.constants import ERROR_MESSAGES, TASKS, WEBHOOK_MESSAGES from open_webui.env import ( @@ -92,6 +93,7 @@ from open_webui.env import ( WEBUI_SESSION_COOKIE_SAME_SITE, WEBUI_SESSION_COOKIE_SECURE, WEBUI_URL, + RESET_CONFIG_ON_START, ) from fastapi import ( Depends, @@ -187,6 +189,9 @@ https://github.com/open-webui/open-webui async def lifespan(app: FastAPI): run_migrations() + if RESET_CONFIG_ON_START: + reset_config() + asyncio.create_task(periodic_usage_pool_cleanup()) yield diff --git a/package-lock.json b/package-lock.json index f7039ed6e..72a3cc6c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "open-webui", - "version": "0.3.28", + "version": "0.3.29", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "open-webui", - "version": "0.3.28", + "version": "0.3.29", "dependencies": { "@codemirror/lang-javascript": "^6.2.2", "@codemirror/lang-python": "^6.1.6", diff --git a/package.json b/package.json index 14db68798..ba3f5295d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-webui", - "version": "0.3.28", + "version": "0.3.29", "private": true, "scripts": { "dev": "npm run pyodide:fetch && vite dev --host", diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index b6e2210a4..b5db7d078 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -357,6 +357,7 @@ if ($page.url.searchParams.get('call') === 'true') { showCallOverlay.set(true); + showControls.set(true); } selectedModels = selectedModels.map((modelId) => @@ -482,11 +483,12 @@ } } + await tick(); + if ($chatId == chatId) { if (!$temporaryChatEnabled) { chat = await updateChatById(localStorage.token, chatId, { models: selectedModels, - messages: messages, history: history, params: params, files: chatFiles @@ -1133,13 +1135,6 @@ } } } - - await chatCompletedHandler( - _chatId, - model.id, - responseMessageId, - createMessagesList(responseMessageId) - ); } else { if (res !== null) { const error = await res.json(); @@ -1168,11 +1163,18 @@ (status) => status.action !== 'knowledge_search' ); } - - history.messages[responseMessageId] = responseMessage; } await saveChatHandler(_chatId); + history.messages[responseMessageId] = responseMessage; + + await chatCompletedHandler( + _chatId, + model.id, + responseMessageId, + createMessagesList(responseMessageId) + ); + stopResponseFlag = false; await tick(); @@ -1429,13 +1431,6 @@ } } - await chatCompletedHandler( - _chatId, - model.id, - responseMessageId, - createMessagesList(responseMessageId) - ); - if ($settings.notificationEnabled && !document.hasFocus()) { const notification = new Notification(`${model.id}`, { body: responseMessage.content, @@ -1463,6 +1458,13 @@ history.messages[responseMessageId] = responseMessage; + await chatCompletedHandler( + _chatId, + model.id, + responseMessageId, + createMessagesList(responseMessageId) + ); + stopResponseFlag = false; await tick(); diff --git a/src/lib/utils/marked/katex-extension.ts b/src/lib/utils/marked/katex-extension.ts index e99fcad31..7b99187b3 100644 --- a/src/lib/utils/marked/katex-extension.ts +++ b/src/lib/utils/marked/katex-extension.ts @@ -1,14 +1,13 @@ import katex from 'katex'; const DELIMITER_LIST = [ - { left: '$$\n', right: '\n$$', display: true }, - { left: '$$', right: '$$', display: false }, // This should be on top to prevent conflict with $ delimiter + { left: '$$', right: '$$', display: true }, { left: '$', right: '$', display: false }, { left: '\\pu{', right: '}', display: false }, { left: '\\ce{', right: '}', display: false }, { left: '\\(', right: '\\)', display: false }, - { left: '\\[\n', right: '\n\\]', display: true }, - { left: '\\[', right: '\\]', display: false } + { left: '\\[', right: '\\]', display: true }, + { left: '\\begin{equation}', right: '\\end{equation}', display: true } ]; // const DELIMITER_LIST = [ @@ -34,14 +33,21 @@ function generateRegexRules(delimiters) { const escapedRight = escapeRegex(right); if (!display) { + // For inline delimiters, we match everyting inlinePatterns.push(`${escapedLeft}((?:\\\\[^]|[^\\\\])+?)${escapedRight}`); } else { - blockPatterns.push(`${escapedLeft}((?:\\\\[^]|[^\\\\])+?)${escapedRight}`); + // Block delimiters doubles as inline delimiters when not followed by a newline + inlinePatterns.push(`${escapedLeft}(?!\\n)((?:\\\\[^]|[^\\\\])+?)(?!\\n)${escapedRight}`); + blockPatterns.push(`${escapedLeft}\\n((?:\\\\[^]|[^\\\\])+?)\\n${escapedRight}`); } }); - const inlineRule = new RegExp(`^(${inlinePatterns.join('|')})(?=[\\s?!.,:?!。,:]|$)`, 'u'); - const blockRule = new RegExp(`^(${blockPatterns.join('|')})(?=[\\s?!.,:?!。,:]|$)`, 'u'); + // Math formulas can end in special characters + const inlineRule = new RegExp( + `^(${inlinePatterns.join('|')})(?=[\\s?。,!-\/:-@[-\`{-~]|$)`, + 'u' + ); + const blockRule = new RegExp(`^(${blockPatterns.join('|')})(?=[\\s?。,!-\/:-@[-\`{-~]|$)`, 'u'); return { inlineRule, blockRule }; } @@ -50,10 +56,7 @@ const { inlineRule, blockRule } = generateRegexRules(DELIMITER_LIST); export default function (options = {}) { return { - extensions: [ - blockKatex(options), // This should be on top to prevent conflict with inline delimiters. - inlineKatex(options) - ] + extensions: [inlineKatex(options), blockKatex(options)] }; } @@ -86,7 +89,9 @@ function katexStart(src, displayMode: boolean) { return; } - const f = index === 0 || indexSrc.charAt(index - 1) === ' '; + // Check if the delimiter is preceded by a special character. + // If it does, then it's potentially a math formula. + const f = index === 0 || indexSrc.charAt(index - 1).match(/[\s?。,!-\/:-@[-`{-~]/); if (f) { const possibleKatex = indexSrc.substring(index);