diff --git a/CHANGELOG.md b/CHANGELOG.md index 842276c28..a62e18871 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ 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.4.6] - 2024-11-26 + +### Added + +- **🌍 Enhanced Translations**: Various language translations improved to make the WebUI more accessible and user-friendly worldwide. + +### Fixed + +- **✏️ Textarea Shifting Bug**: Resolved the issue where the textarea shifted unexpectedly, ensuring a smoother typing experience. +- **⚙️ Model Configuration Modal**: Fixed the issue where the models configuration modal introduced in 0.4.5 wasn’t working for some users. +- **🔍 Legacy Query Support**: Restored functionality for custom query generation in RAG when using legacy prompts, ensuring both default and custom templates now work seamlessly. +- **⚡ Improved General Reliability**: Various minor fixes improve platform stability and ensure a smoother overall experience across workflows. + ## [0.4.5] - 2024-11-26 ### Added diff --git a/backend/open_webui/apps/retrieval/utils.py b/backend/open_webui/apps/retrieval/utils.py index 35159f80d..bf939ecf1 100644 --- a/backend/open_webui/apps/retrieval/utils.py +++ b/backend/open_webui/apps/retrieval/utils.py @@ -429,7 +429,7 @@ def generate_openai_batch_embeddings( def generate_ollama_batch_embeddings( - model: str, texts: list[str], url: str, key: str + model: str, texts: list[str], url: str, key: str = "" ) -> Optional[list[list[float]]]: try: r = requests.post( diff --git a/backend/open_webui/apps/webui/routers/configs.py b/backend/open_webui/apps/webui/routers/configs.py index b19fc1745..7466e6fda 100644 --- a/backend/open_webui/apps/webui/routers/configs.py +++ b/backend/open_webui/apps/webui/routers/configs.py @@ -1,10 +1,12 @@ -from open_webui.config import BannerModel from fastapi import APIRouter, Depends, Request from pydantic import BaseModel + +from typing import Optional + from open_webui.utils.utils import get_admin_user, get_verified_user - - from open_webui.config import get_config, save_config +from open_webui.config import BannerModel + router = APIRouter() @@ -38,8 +40,8 @@ async def export_config(user=Depends(get_admin_user)): # SetDefaultModels ############################ class ModelsConfigForm(BaseModel): - DEFAULT_MODELS: str - MODEL_ORDER_LIST: list[str] + DEFAULT_MODELS: Optional[str] + MODEL_ORDER_LIST: Optional[list[str]] @router.get("/models", response_model=ModelsConfigForm) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 3c1ee798d..0a76626c1 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -975,7 +975,7 @@ QUERY_GENERATION_PROMPT_TEMPLATE = PersistentConfig( ) DEFAULT_QUERY_GENERATION_PROMPT_TEMPLATE = """### Task: -Analyze the chat history to determine the necessity of generating search queries. By default, **prioritize generating 1-3 broad and relevant search queries** unless it is absolutely certain that no additional information is required. The aim is to retrieve comprehensive, updated, and valuable information even with minimal uncertainty. If no search is unequivocally needed, return an empty list. +Analyze the chat history to determine the necessity of generating search queries, in the given language. By default, **prioritize generating 1-3 broad and relevant search queries** unless it is absolutely certain that no additional information is required. The aim is to retrieve comprehensive, updated, and valuable information even with minimal uncertainty. If no search is unequivocally needed, return an empty list. ### Guidelines: - Respond **EXCLUSIVELY** with a JSON object. Any form of extra commentary, explanation, or additional text is strictly prohibited. @@ -983,7 +983,7 @@ Analyze the chat history to determine the necessity of generating search queries - If and only if it is entirely certain that no useful results can be retrieved by a search, return: { "queries": [] }. - Err on the side of suggesting search queries if there is **any chance** they might provide useful or updated information. - Be concise and focused on composing high-quality search queries, avoiding unnecessary elaboration, commentary, or assumptions. -- Assume today's date is: {{CURRENT_DATE}}. +- Today's date is: {{CURRENT_DATE}}. - Always prioritize providing actionable and broad queries that maximize informational coverage. ### Output: diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 0dca21b08..aa936db47 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -531,9 +531,16 @@ async def chat_completion_files_handler( queries_response = queries_response["choices"][0]["message"]["content"] try: + bracket_start = queries_response.find("{") + bracket_end = queries_response.rfind("}") + 1 + + if bracket_start == -1 or bracket_end == -1: + raise Exception("No JSON object found in the response") + + queries_response = queries_response[bracket_start:bracket_end] queries_response = json.loads(queries_response) except Exception as e: - queries_response = {"queries": []} + queries_response = {"queries": [queries_response]} queries = queries_response.get("queries", []) except Exception as e: diff --git a/backend/open_webui/utils/task.py b/backend/open_webui/utils/task.py index b6d0d3bce..3b71ba746 100644 --- a/backend/open_webui/utils/task.py +++ b/backend/open_webui/utils/task.py @@ -25,12 +25,14 @@ def prompt_template( # Format the date to YYYY-MM-DD formatted_date = current_date.strftime("%Y-%m-%d") formatted_time = current_date.strftime("%I:%M:%S %p") + formatted_weekday = current_date.strftime("%A") template = template.replace("{{CURRENT_DATE}}", formatted_date) template = template.replace("{{CURRENT_TIME}}", formatted_time) template = template.replace( "{{CURRENT_DATETIME}}", f"{formatted_date} {formatted_time}" ) + template = template.replace("{{CURRENT_WEEKDAY}}", formatted_weekday) if user_name: # Replace {{USER_NAME}} in the template with the user's name diff --git a/package-lock.json b/package-lock.json index 6b899042c..eaa39b6db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "open-webui", - "version": "0.4.5", + "version": "0.4.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "open-webui", - "version": "0.4.5", + "version": "0.4.6", "dependencies": { "@codemirror/lang-javascript": "^6.2.2", "@codemirror/lang-python": "^6.1.6", diff --git a/package.json b/package.json index 0db0d88f2..80e7b4fc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-webui", - "version": "0.4.5", + "version": "0.4.6", "private": true, "scripts": { "dev": "npm run pyodide:fetch && vite dev --host", diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index a33610c31..2e9e836a8 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -367,15 +367,13 @@ export const generateQueries = async ( throw error; } - try { - // Step 1: Safely extract the response string - const response = res?.choices[0]?.message?.content ?? ''; + // Step 1: Safely extract the response string + const response = res?.choices[0]?.message?.content ?? ''; - // Step 3: Find the relevant JSON block within the response + try { const jsonStartIndex = response.indexOf('{'); const jsonEndIndex = response.lastIndexOf('}'); - // Step 4: Check if we found a valid JSON block (with both `{` and `}`) if (jsonStartIndex !== -1 && jsonEndIndex !== -1) { const jsonResponse = response.substring(jsonStartIndex, jsonEndIndex + 1); @@ -390,12 +388,12 @@ export const generateQueries = async ( } } - // If no valid JSON block found, return an empty array - return []; + // If no valid JSON block found, return response as is + return [response]; } catch (e) { // Catch and safely return empty array on any parsing errors console.error('Failed to parse response: ', e); - return []; + return [response]; } }; diff --git a/src/lib/components/admin/Settings/Interface.svelte b/src/lib/components/admin/Settings/Interface.svelte index 3043ffae4..2fee518ee 100644 --- a/src/lib/components/admin/Settings/Interface.svelte +++ b/src/lib/components/admin/Settings/Interface.svelte @@ -55,255 +55,176 @@ }; -