Unverified Commit 14646e84 authored by Timothy Jaeryang Baek's avatar Timothy Jaeryang Baek Committed by GitHub
Browse files

Merge pull request #2782 from open-webui/dev

0.2.3
parents be08dbf0 ba56edab
......@@ -5,6 +5,21 @@ 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.2.3] - 2024-06-03
### Added
- **📁 Export Chat as JSON**: You can now export individual chats as JSON files from the navbar menu by navigating to 'Download > Export Chat'. This makes sharing specific conversations easier.
- **✏️ Edit Titles with Double Click**: Double-click on titles to rename them quickly and efficiently.
- **🧩 Batch Multiple Embeddings**: Introduced 'RAG_EMBEDDING_OPENAI_BATCH_SIZE' to process multiple embeddings in a batch, enhancing performance for large datasets.
- **🌍 Improved Translations**: Enhanced the translation quality across various languages for a better user experience.
### Fixed
- **🛠️ Modelfile Migration Script**: Fixed an issue where the modelfile migration script would fail if an invalid modelfile was encountered.
- **💬 Zhuyin Input Method on Mac**: Resolved an issue where using the Zhuyin input method in the Web UI on a Mac caused text to send immediately upon pressing the enter key, leading to incorrect input.
- **🔊 Local TTS Voice Selection**: Fixed the issue where the selected local Text-to-Speech (TTS) voice was not being displayed in settings.
## [0.2.2] - 2024-06-02
### Added
......
import logging
import requests
from typing import List
from apps.rag.search.main import SearchResult
from config import SRC_LOG_LEVELS
......@@ -9,20 +10,52 @@ log = logging.getLogger(__name__)
log.setLevel(SRC_LOG_LEVELS["RAG"])
def search_searxng(query_url: str, query: str, count: int) -> list[SearchResult]:
"""Search a SearXNG instance for a query and return the results as a list of SearchResult objects.
def search_searxng(query_url: str, query: str, count: int, **kwargs) -> List[SearchResult]:
"""
Search a SearXNG instance for a given query and return the results as a list of SearchResult objects.
The function allows passing additional parameters such as language or time_range to tailor the search result.
Args:
query_url (str): The URL of the SearXNG instance to search. Must contain "<query>" as a placeholder
query (str): The query to search for
query_url (str): The base URL of the SearXNG server with a placeholder for the query "<query>".
query (str): The search term or question to find in the SearXNG database.
count (int): The maximum number of results to retrieve from the search.
Keyword Args:
language (str): Language filter for the search results; e.g., "en-US". Defaults to an empty string.
time_range (str): Time range for filtering results by date; e.g., "2023-04-05..today" or "all-time". Defaults to ''.
categories: (Optional[List[str]]): Specific categories within which the search should be performed, defaulting to an empty string if not provided.
Returns:
List[SearchResult]: A list of SearchResults sorted by relevance score in descending order.
Raise:
requests.exceptions.RequestException: If a request error occurs during the search process.
"""
url = query_url.replace("<query>", query)
if "&format=json" not in url:
url += "&format=json"
log.debug(f"searching {url}")
# Default values for optional parameters are provided as empty strings or None when not specified.
language = kwargs.get('language', 'en-US')
time_range = kwargs.get('time_range', '')
categories = ''.join(kwargs.get('categories', []))
params = {
"q": query,
"format": "json",
"pageno": 1,
"results_per_page": count,
'language': language,
'time_range': time_range,
'engines': '',
'categories': categories,
'theme': 'simple',
'image_proxy': 0
r = requests.get(
url,
}
log.debug(f"searching {query_url}")
response = requests.get(
query_url,
headers={
"User-Agent": "Open WebUI (https://github.com/open-webui/open-webui) RAG Bot",
"Accept": "text/html",
......@@ -30,15 +63,17 @@ def search_searxng(query_url: str, query: str, count: int) -> list[SearchResult]
"Accept-Language": "en-US,en;q=0.5",
"Connection": "keep-alive",
},
params=params,
)
r.raise_for_status()
json_response = r.json()
response.raise_for_status() # Raise an exception for HTTP errors.
json_response = response.json()
results = json_response.get("results", [])
sorted_results = sorted(results, key=lambda x: x.get("score", 0), reverse=True)
return [
SearchResult(
link=result["url"], title=result.get("title"), snippet=result.get("content")
)
for result in sorted_results[:count]
for result in sorted_results
]
......@@ -123,11 +123,25 @@ def parse_ollama_modelfile(model_text):
"repeat_penalty": float,
"temperature": float,
"seed": int,
"stop": str,
"tfs_z": float,
"num_predict": int,
"top_k": int,
"top_p": float,
"num_keep": int,
"typical_p": float,
"presence_penalty": float,
"frequency_penalty": float,
"penalize_newline": bool,
"numa": bool,
"num_batch": int,
"num_gpu": int,
"main_gpu": int,
"low_vram": bool,
"f16_kv": bool,
"vocab_only": bool,
"use_mmap": bool,
"use_mlock": bool,
"num_thread": int,
}
data = {"base_model_id": None, "params": {}}
......@@ -156,10 +170,18 @@ def parse_ollama_modelfile(model_text):
param_match = re.search(rf"PARAMETER {param} (.+)", model_text, re.IGNORECASE)
if param_match:
value = param_match.group(1)
if param_type == int:
value = int(value)
elif param_type == float:
value = float(value)
try:
if param_type == int:
value = int(value)
elif param_type == float:
value = float(value)
elif param_type == bool:
value = value.lower() == "true"
except Exception as e:
print(e)
continue
data["params"][param] = value
# Parse adapter
......
{
"name": "open-webui",
"version": "0.2.2",
"version": "0.2.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "open-webui",
"version": "0.2.2",
"version": "0.2.3",
"dependencies": {
"@pyscript/core": "^0.4.32",
"@sveltejs/adapter-node": "^1.3.1",
......
{
"name": "open-webui",
"version": "0.2.2",
"version": "0.2.3",
"private": true,
"scripts": {
"dev": "npm run pyodide:fetch && vite dev --host",
......
......@@ -810,10 +810,7 @@
? $i18n.t('Listening...')
: $i18n.t('Send a Message')}
bind:value={prompt}
on:keypress={(e) => {}}
on:keydown={async (e) => {
// Check if the device is not a mobile device or if it is a mobile device, check if it is not a touch device
// This is to prevent the Enter key from submitting the prompt on mobile devices
on:keypress={(e) => {
if (
!$mobile ||
!(
......@@ -822,28 +819,18 @@
navigator.msMaxTouchPoints > 0
)
) {
// Check if Enter is pressed
// Check if Shift key is not pressed
// Prevent Enter key from creating a new line
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
}
const commandOptionButton = [
...document.getElementsByClassName('selected-command-option-button')
]?.at(-1);
if (!commandOptionButton) {
if (e.key === 'Enter' && !e.shiftKey && prompt !== '') {
submitPrompt(prompt, user);
return;
}
if (e.key === 'Enter' && e.shiftKey && prompt !== '') {
return;
}
// Submit the prompt when Enter key is pressed
if (prompt !== '' && e.key === 'Enter' && !e.shiftKey) {
submitPrompt(prompt, user);
}
}
}}
on:keydown={async (e) => {
const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac
// Check if Ctrl + R is pressed
......@@ -904,7 +891,9 @@
...document.getElementsByClassName('selected-command-option-button')
]?.at(-1);
if (commandOptionButton) {
if (e.shiftKey) {
prompt = `${prompt}\n`;
} else if (commandOptionButton) {
commandOptionButton?.click();
} else {
document.getElementById('send-message-button')?.click();
......
......@@ -3,6 +3,7 @@
import { user, settings } from '$lib/stores';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import { toast } from 'svelte-sonner';
import Switch from '$lib/components/common/Switch.svelte';
const dispatch = createEventDispatcher();
const i18n = getContext('i18n');
......@@ -13,6 +14,7 @@
let OpenAIUrl = '';
let OpenAIKey = '';
let OpenAISpeaker = '';
let STTEngines = ['', 'openai'];
let STTEngine = '';
......@@ -20,6 +22,7 @@
let conversationMode = false;
let speechAutoSend = false;
let responseAutoPlayback = false;
let nonLocalVoices = false;
let TTSEngines = ['', 'openai'];
let TTSEngine = '';
......@@ -86,14 +89,14 @@
url: OpenAIUrl,
key: OpenAIKey,
model: model,
speaker: speaker
speaker: OpenAISpeaker
});
if (res) {
OpenAIUrl = res.OPENAI_API_BASE_URL;
OpenAIKey = res.OPENAI_API_KEY;
model = res.OPENAI_API_MODEL;
speaker = res.OPENAI_API_VOICE;
OpenAISpeaker = res.OPENAI_API_VOICE;
}
}
};
......@@ -105,6 +108,7 @@
STTEngine = $settings?.audio?.STTEngine ?? '';
TTSEngine = $settings?.audio?.TTSEngine ?? '';
nonLocalVoices = $settings.audio?.nonLocalVoices ?? false;
speaker = $settings?.audio?.speaker ?? '';
model = $settings?.audio?.model ?? '';
......@@ -122,7 +126,10 @@
OpenAIUrl = res.OPENAI_API_BASE_URL;
OpenAIKey = res.OPENAI_API_KEY;
model = res.OPENAI_API_MODEL;
speaker = res.OPENAI_API_VOICE;
OpenAISpeaker = res.OPENAI_API_VOICE;
if (TTSEngine === 'openai') {
speaker = OpenAISpeaker;
}
}
}
});
......@@ -138,8 +145,14 @@
audio: {
STTEngine: STTEngine !== '' ? STTEngine : undefined,
TTSEngine: TTSEngine !== '' ? TTSEngine : undefined,
speaker: speaker !== '' ? speaker : undefined,
model: model !== '' ? model : undefined
speaker:
(TTSEngine === 'openai' ? OpenAISpeaker : speaker) !== ''
? TTSEngine === 'openai'
? OpenAISpeaker
: speaker
: undefined,
model: model !== '' ? model : undefined,
nonLocalVoices: nonLocalVoices
}
});
dispatch('save');
......@@ -227,7 +240,7 @@
on:change={(e) => {
if (e.target.value === 'openai') {
getOpenAIVoices();
speaker = 'alloy';
OpenAISpeaker = 'alloy';
model = 'tts-1';
} else {
getWebAPIVoices();
......@@ -290,16 +303,27 @@
<select
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
bind:value={speaker}
placeholder="Select a voice"
>
<option value="" selected>{$i18n.t('Default')}</option>
{#each voices.filter((v) => v.localService === true) as voice}
<option value={voice.name} class="bg-gray-100 dark:bg-gray-700">{voice.name}</option
<option value="" selected={speaker !== ''}>{$i18n.t('Default')}</option>
{#each voices.filter((v) => nonLocalVoices || v.localService === true) as voice}
<option
value={voice.name}
class="bg-gray-100 dark:bg-gray-700"
selected={speaker === voice.name}>{voice.name}</option
>
{/each}
</select>
</div>
</div>
<div class="flex items-center justify-between mb-1">
<div class="text-sm">
{$i18n.t('Allow non-local voices')}
</div>
<div class="mt-1">
<Switch bind:state={nonLocalVoices} />
</div>
</div>
</div>
{:else if TTSEngine === 'openai'}
<div>
......@@ -309,7 +333,7 @@
<input
list="voice-list"
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
bind:value={speaker}
bind:value={OpenAISpeaker}
placeholder="Select a voice"
/>
......
......@@ -205,6 +205,10 @@
await archiveChatById(localStorage.token, id);
await chats.set(await getChatList(localStorage.token));
};
const focusEdit = async (node: HTMLInputElement) => {
node.focus();
};
</script>
<ShareChatModal bind:show={showShareChatModal} chatId={shareChatId} />
......@@ -489,7 +493,11 @@
? 'bg-gray-100 dark:bg-gray-950'
: 'group-hover:bg-gray-100 dark:group-hover:bg-gray-950'} whitespace-nowrap text-ellipsis"
>
<input bind:value={chatTitle} class=" bg-transparent w-full outline-none mr-10" />
<input
use:focusEdit
bind:value={chatTitle}
class=" bg-transparent w-full outline-none mr-10"
/>
</div>
{:else}
<a
......@@ -507,6 +515,10 @@
showSidebar.set(false);
}
}}
on:dblclick={() => {
chatTitle = chat.title;
chatTitleEditId = chat.id;
}}
draggable="false"
>
<div class=" flex self-center flex-1 w-full">
......
......@@ -37,6 +37,7 @@
"All Users": "جميع المستخدمين",
"Allow": "يسمح",
"Allow Chat Deletion": "يستطيع حذف المحادثات",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "الأحرف الأبجدية الرقمية والواصلات",
"Already have an account?": "هل تملك حساب ؟",
"an assistant": "مساعد",
......@@ -206,6 +207,7 @@
"Experimental": "تجريبي",
"Export": "تصدير",
"Export All Chats (All Users)": "تصدير جميع الدردشات (جميع المستخدمين)",
"Export chat (.json)": "",
"Export Chats": "تصدير جميع الدردشات",
"Export Documents Mapping": "تصدير وثائق الخرائط",
"Export Models": "نماذج التصدير",
......
......@@ -37,6 +37,7 @@
"All Users": "Всички Потребители",
"Allow": "Позволи",
"Allow Chat Deletion": "Позволи Изтриване на Чат",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "алфанумерични знаци и тире",
"Already have an account?": "Вече имате акаунт? ",
"an assistant": "асистент",
......@@ -206,6 +207,7 @@
"Experimental": "Експериментално",
"Export": "Износ",
"Export All Chats (All Users)": "Експортване на всички чатове (За всички потребители)",
"Export chat (.json)": "",
"Export Chats": "Експортване на чатове",
"Export Documents Mapping": "Експортване на документен мапинг",
"Export Models": "Експортиране на модели",
......
......@@ -37,6 +37,7 @@
"All Users": "সব ইউজার",
"Allow": "অনুমোদন",
"Allow Chat Deletion": "চ্যাট ডিলিট করতে দিন",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "ইংরেজি অক্ষর, সংখ্যা এবং হাইফেন",
"Already have an account?": "আগে থেকেই একাউন্ট আছে?",
"an assistant": "একটা এসিস্ট্যান্ট",
......@@ -206,6 +207,7 @@
"Experimental": "পরিক্ষামূলক",
"Export": "রপ্তানি",
"Export All Chats (All Users)": "সব চ্যাট এক্সপোর্ট করুন (সব ইউজারের)",
"Export chat (.json)": "",
"Export Chats": "চ্যাটগুলো এক্সপোর্ট করুন",
"Export Documents Mapping": "ডকুমেন্টসমূহ ম্যাপিং এক্সপোর্ট করুন",
"Export Models": "রপ্তানি মডেল",
......
......@@ -37,6 +37,7 @@
"All Users": "Tots els Usuaris",
"Allow": "Permet",
"Allow Chat Deletion": "Permet la Supressió del Xat",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "caràcters alfanumèrics i guions",
"Already have an account?": "Ja tens un compte?",
"an assistant": "un assistent",
......@@ -206,6 +207,7 @@
"Experimental": "Experimental",
"Export": "Exportar",
"Export All Chats (All Users)": "Exporta Tots els Xats (Tots els Usuaris)",
"Export chat (.json)": "",
"Export Chats": "Exporta Xats",
"Export Documents Mapping": "Exporta el Mapatge de Documents",
"Export Models": "Models d'exportació",
......
......@@ -37,6 +37,7 @@
"All Users": "Ang tanan nga mga tiggamit",
"Allow": "Sa pagtugot",
"Allow Chat Deletion": "Tugoti nga mapapas ang mga chat",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "alphanumeric nga mga karakter ug hyphen",
"Already have an account?": "Naa na kay account ?",
"an assistant": "usa ka katabang",
......@@ -206,6 +207,7 @@
"Experimental": "Eksperimento",
"Export": "",
"Export All Chats (All Users)": "I-export ang tanan nga mga chat (Tanan nga tiggamit)",
"Export chat (.json)": "",
"Export Chats": "I-export ang mga chat",
"Export Documents Mapping": "I-export ang pagmapa sa dokumento",
"Export Models": "",
......
......@@ -37,6 +37,7 @@
"All Users": "Alle Benutzer",
"Allow": "Erlauben",
"Allow Chat Deletion": "Chat Löschung erlauben",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "alphanumerische Zeichen und Bindestriche",
"Already have an account?": "Hast du vielleicht schon ein Account?",
"an assistant": "ein Assistent",
......@@ -206,6 +207,7 @@
"Experimental": "Experimentell",
"Export": "Exportieren",
"Export All Chats (All Users)": "Alle Chats exportieren (alle Benutzer)",
"Export chat (.json)": "",
"Export Chats": "Chats exportieren",
"Export Documents Mapping": "Dokumentenmapping exportieren",
"Export Models": "Modelle exportieren",
......
......@@ -37,6 +37,7 @@
"All Users": "All Users",
"Allow": "Allow",
"Allow Chat Deletion": "Allow Delete Chats",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "so alpha, many hyphen",
"Already have an account?": "Such account exists?",
"an assistant": "such assistant",
......@@ -206,6 +207,7 @@
"Experimental": "Much Experiment",
"Export": "",
"Export All Chats (All Users)": "Export All Chats (All Doggos)",
"Export chat (.json)": "",
"Export Chats": "Export Barks",
"Export Documents Mapping": "Export Mappings of Dogos",
"Export Models": "",
......
......@@ -37,6 +37,7 @@
"All Users": "",
"Allow": "",
"Allow Chat Deletion": "",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "",
"Already have an account?": "",
"an assistant": "",
......@@ -206,6 +207,7 @@
"Experimental": "",
"Export": "",
"Export All Chats (All Users)": "",
"Export chat (.json)": "",
"Export Chats": "",
"Export Documents Mapping": "",
"Export Models": "",
......
......@@ -37,6 +37,7 @@
"All Users": "",
"Allow": "",
"Allow Chat Deletion": "",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "",
"Already have an account?": "",
"an assistant": "",
......@@ -206,6 +207,7 @@
"Experimental": "",
"Export": "",
"Export All Chats (All Users)": "",
"Export chat (.json)": "",
"Export Chats": "",
"Export Documents Mapping": "",
"Export Models": "",
......
......@@ -37,6 +37,7 @@
"All Users": "Todos los Usuarios",
"Allow": "Permitir",
"Allow Chat Deletion": "Permitir Borrar Chats",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "caracteres alfanuméricos y guiones",
"Already have an account?": "¿Ya tienes una cuenta?",
"an assistant": "un asistente",
......@@ -206,6 +207,7 @@
"Experimental": "Experimental",
"Export": "Exportar",
"Export All Chats (All Users)": "Exportar todos los chats (Todos los usuarios)",
"Export chat (.json)": "",
"Export Chats": "Exportar Chats",
"Export Documents Mapping": "Exportar el mapeo de documentos",
"Export Models": "Modelos de exportación",
......
......@@ -37,6 +37,7 @@
"All Users": "همه کاربران",
"Allow": "اجازه دادن",
"Allow Chat Deletion": "اجازه حذف گپ",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "حروف الفبایی و خط فاصله",
"Already have an account?": "از قبل حساب کاربری دارید؟",
"an assistant": "یک دستیار",
......@@ -206,6 +207,7 @@
"Experimental": "آزمایشی",
"Export": "صادرات",
"Export All Chats (All Users)": "اکسپورت از همه گپ\u200cها(همه کاربران)",
"Export chat (.json)": "",
"Export Chats": "اکسپورت از گپ\u200cها",
"Export Documents Mapping": "اکسپورت از نگاشت اسناد",
"Export Models": "مدل های صادرات",
......
......@@ -37,6 +37,7 @@
"All Users": "Kaikki käyttäjät",
"Allow": "Salli",
"Allow Chat Deletion": "Salli keskustelujen poisto",
"Allow non-local voices": "",
"alphanumeric characters and hyphens": "kirjaimia, numeroita ja väliviivoja",
"Already have an account?": "Onko sinulla jo tili?",
"an assistant": "avustaja",
......@@ -206,6 +207,7 @@
"Experimental": "Kokeellinen",
"Export": "Vienti",
"Export All Chats (All Users)": "Vie kaikki keskustelut (kaikki käyttäjät)",
"Export chat (.json)": "",
"Export Chats": "Vie keskustelut",
"Export Documents Mapping": "Vie asiakirjakartoitus",
"Export Models": "Vie malleja",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment