mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
Merge pull request #16249 from silentoplayz/fix-richtext-getwordatdocpos
fix(frontend): Attempt to resolve TypeError in RichTextInput.svelte
This commit is contained in:
commit
ae2de6b09c
7 changed files with 20 additions and 20 deletions
|
|
@ -465,7 +465,7 @@ export const executeToolServer = async (
|
||||||
...(token && { authorization: `Bearer ${token}` })
|
...(token && { authorization: `Bearer ${token}` })
|
||||||
};
|
};
|
||||||
|
|
||||||
let requestOptions: RequestInit = {
|
const requestOptions: RequestInit = {
|
||||||
method: httpMethod.toUpperCase(),
|
method: httpMethod.toUpperCase(),
|
||||||
headers
|
headers
|
||||||
};
|
};
|
||||||
|
|
@ -818,7 +818,7 @@ export const generateQueries = async (
|
||||||
model: string,
|
model: string,
|
||||||
messages: object[],
|
messages: object[],
|
||||||
prompt: string,
|
prompt: string,
|
||||||
type?: string = 'web_search'
|
type: string = 'web_search'
|
||||||
) => {
|
) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
|
|
@ -1014,7 +1014,7 @@ export const getPipelinesList = async (token: string = '') => {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipelines = res?.data ?? [];
|
const pipelines = res?.data ?? [];
|
||||||
return pipelines;
|
return pipelines;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1157,7 +1157,7 @@ export const getPipelines = async (token: string, urlIdx?: string) => {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipelines = res?.data ?? [];
|
const pipelines = res?.data ?? [];
|
||||||
return pipelines;
|
return pipelines;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ export const generateTextCompletion = async (token: string = '', model: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generateChatCompletion = async (token: string = '', body: object) => {
|
export const generateChatCompletion = async (token: string = '', body: object) => {
|
||||||
let controller = new AbortController();
|
const controller = new AbortController();
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
const res = await fetch(`${OLLAMA_API_BASE_URL}/api/chat`, {
|
const res = await fetch(`${OLLAMA_API_BASE_URL}/api/chat`, {
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ export const getUsers = async (
|
||||||
let error = null;
|
let error = null;
|
||||||
let res = null;
|
let res = null;
|
||||||
|
|
||||||
let searchParams = new URLSearchParams();
|
const searchParams = new URLSearchParams();
|
||||||
|
|
||||||
searchParams.set('page', `${page}`);
|
searchParams.set('page', `${page}`);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ const createIsLoadingStore = (i18n: i18nType) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initI18n = (defaultLocale?: string | undefined) => {
|
export const initI18n = (defaultLocale?: string | undefined) => {
|
||||||
let detectionOrder = defaultLocale
|
const detectionOrder = defaultLocale
|
||||||
? ['querystring', 'localStorage']
|
? ['querystring', 'localStorage']
|
||||||
: ['querystring', 'localStorage', 'navigator'];
|
: ['querystring', 'localStorage', 'navigator'];
|
||||||
let fallbackDefaultLocale = defaultLocale ? [defaultLocale] : ['en-US'];
|
const fallbackDefaultLocale = defaultLocale ? [defaultLocale] : ['en-US'];
|
||||||
|
|
||||||
const loadResource = (language: string, namespace: string) =>
|
const loadResource = (language: string, namespace: string) =>
|
||||||
import(`./locales/${language}/${namespace}.json`);
|
import(`./locales/${language}/${namespace}.json`);
|
||||||
|
|
|
||||||
|
|
@ -74,15 +74,15 @@ const readPngChunks = (data) => {
|
||||||
|
|
||||||
if (!isValidPng) throw new Error('Invalid PNG file');
|
if (!isValidPng) throw new Error('Invalid PNG file');
|
||||||
|
|
||||||
let chunks = [];
|
const chunks = [];
|
||||||
let offset = 8; // Skip PNG signature
|
let offset = 8; // Skip PNG signature
|
||||||
|
|
||||||
while (offset < data.length) {
|
while (offset < data.length) {
|
||||||
let length =
|
const length =
|
||||||
(data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | data[offset + 3];
|
(data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | data[offset + 3];
|
||||||
let type = String.fromCharCode.apply(null, data.slice(offset + 4, offset + 8));
|
const type = String.fromCharCode.apply(null, data.slice(offset + 4, offset + 8));
|
||||||
let chunkData = data.slice(offset + 8, offset + 8 + length);
|
const chunkData = data.slice(offset + 8, offset + 8 + length);
|
||||||
let crc =
|
const crc =
|
||||||
(data[offset + 8 + length] << 24) |
|
(data[offset + 8 + length] << 24) |
|
||||||
(data[offset + 8 + length + 1] << 16) |
|
(data[offset + 8 + length + 1] << 16) |
|
||||||
(data[offset + 8 + length + 2] << 8) |
|
(data[offset + 8 + length + 2] << 8) |
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ const ALLOWED_SURROUNDING_CHARS =
|
||||||
// const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
|
// const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
|
||||||
// const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
// const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
||||||
|
|
||||||
let inlinePatterns = [];
|
const inlinePatterns = [];
|
||||||
let blockPatterns = [];
|
const blockPatterns = [];
|
||||||
|
|
||||||
function escapeRegex(string) {
|
function escapeRegex(string) {
|
||||||
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||||
|
|
@ -69,7 +69,7 @@ export default function (options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function katexStart(src, displayMode: boolean) {
|
function katexStart(src, displayMode: boolean) {
|
||||||
let ruleReg = displayMode ? blockRule : inlineRule;
|
const ruleReg = displayMode ? blockRule : inlineRule;
|
||||||
|
|
||||||
let indexSrc = src;
|
let indexSrc = src;
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ function katexStart(src, displayMode: boolean) {
|
||||||
let startIndex = -1;
|
let startIndex = -1;
|
||||||
let startDelimiter = '';
|
let startDelimiter = '';
|
||||||
let endDelimiter = '';
|
let endDelimiter = '';
|
||||||
for (let delimiter of DELIMITER_LIST) {
|
for (const delimiter of DELIMITER_LIST) {
|
||||||
if (delimiter.display !== displayMode) {
|
if (delimiter.display !== displayMode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -115,8 +115,8 @@ function katexStart(src, displayMode: boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function katexTokenizer(src, tokens, displayMode: boolean) {
|
function katexTokenizer(src, tokens, displayMode: boolean) {
|
||||||
let ruleReg = displayMode ? blockRule : inlineRule;
|
const ruleReg = displayMode ? blockRule : inlineRule;
|
||||||
let type = displayMode ? 'blockKatex' : 'inlineKatex';
|
const type = displayMode ? 'blockKatex' : 'inlineKatex';
|
||||||
|
|
||||||
const match = src.match(ruleReg);
|
const match = src.match(ruleReg);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ async function loadPyodideAndPackages(packages: string[] = []) {
|
||||||
packages: ['micropip']
|
packages: ['micropip']
|
||||||
});
|
});
|
||||||
|
|
||||||
let mountDir = '/mnt';
|
const mountDir = '/mnt';
|
||||||
self.pyodide.FS.mkdirTree(mountDir);
|
self.pyodide.FS.mkdirTree(mountDir);
|
||||||
// self.pyodide.FS.mount(self.pyodide.FS.filesystems.IDBFS, {}, mountDir);
|
// self.pyodide.FS.mount(self.pyodide.FS.filesystems.IDBFS, {}, mountDir);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue