mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import { deleteAllFiles, deleteFileById } from '$lib/apis/files';
|
||||
import {
|
||||
getQuerySettings,
|
||||
scanDocs,
|
||||
processDocsDir,
|
||||
updateQuerySettings,
|
||||
resetVectorDB,
|
||||
getEmbeddingConfig,
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
const scanHandler = async () => {
|
||||
scanDirLoading = true;
|
||||
const res = await scanDocs(localStorage.token);
|
||||
const res = await processDocsDir(localStorage.token);
|
||||
scanDirLoading = false;
|
||||
|
||||
if (res) {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
updateChatById
|
||||
} from '$lib/apis/chats';
|
||||
import { generateOpenAIChatCompletion } from '$lib/apis/openai';
|
||||
import { runWebSearch } from '$lib/apis/retrieval';
|
||||
import { processWebSearch } from '$lib/apis/retrieval';
|
||||
import { createOpenAITextStream } from '$lib/apis/streaming';
|
||||
import { queryMemory } from '$lib/apis/memories';
|
||||
import { getAndUpdateUserLocation, getUserSettings } from '$lib/apis/users';
|
||||
@@ -1737,7 +1737,7 @@
|
||||
});
|
||||
history.messages[responseMessageId] = responseMessage;
|
||||
|
||||
const results = await runWebSearch(localStorage.token, searchQuery).catch((error) => {
|
||||
const results = await processWebSearch(localStorage.token, searchQuery).catch((error) => {
|
||||
console.log(error);
|
||||
toast.error(error);
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
chatFiles.splice(fileIdx, 1);
|
||||
chatFiles = chatFiles;
|
||||
}}
|
||||
on:click={() => {
|
||||
console.log(file);
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Models from './Commands/Models.svelte';
|
||||
|
||||
import { removeLastWordFromString } from '$lib/utils';
|
||||
import { uploadWebToVectorDB, uploadYoutubeTranscriptionToVectorDB } from '$lib/apis/retrieval';
|
||||
import { processWeb, processYoutubeVideo } from '$lib/apis/retrieval';
|
||||
|
||||
export let prompt = '';
|
||||
export let files = [];
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
try {
|
||||
files = [...files, doc];
|
||||
const res = await uploadWebToVectorDB(localStorage.token, '', url);
|
||||
const res = await processWeb(localStorage.token, '', url);
|
||||
|
||||
if (res) {
|
||||
doc.status = 'processed';
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
try {
|
||||
files = [...files, doc];
|
||||
const res = await uploadYoutubeTranscriptionToVectorDB(localStorage.token, url);
|
||||
const res = await processYoutubeVideo(localStorage.token, url);
|
||||
|
||||
if (res) {
|
||||
doc.status = 'processed';
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
export let colorClassName = 'bg-white dark:bg-gray-800';
|
||||
export let url: string | null = null;
|
||||
|
||||
export let clickHandler: Function | null = null;
|
||||
|
||||
export let dismissible = false;
|
||||
export let status = 'processed';
|
||||
|
||||
@@ -17,7 +15,7 @@
|
||||
export let type: string;
|
||||
export let size: number;
|
||||
|
||||
function formatSize(size) {
|
||||
const formatSize = (size) => {
|
||||
if (size == null) return 'Unknown size';
|
||||
if (typeof size !== 'number' || size < 0) return 'Invalid size';
|
||||
if (size === 0) return '0 B';
|
||||
@@ -29,7 +27,7 @@
|
||||
unitIndex++;
|
||||
}
|
||||
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="relative group">
|
||||
@@ -37,17 +35,7 @@
|
||||
class="h-14 {className} flex items-center space-x-3 {colorClassName} rounded-xl border border-gray-100 dark:border-gray-800 text-left"
|
||||
type="button"
|
||||
on:click={async () => {
|
||||
if (clickHandler === null) {
|
||||
if (url) {
|
||||
if (type === 'file') {
|
||||
window.open(`${url}/content`, '_blank').focus();
|
||||
} else {
|
||||
window.open(`${url}`, '_blank').focus();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clickHandler();
|
||||
}
|
||||
dispatch('click');
|
||||
}}
|
||||
>
|
||||
<div class="p-4 py-[1.1rem] bg-red-400 text-white rounded-l-xl">
|
||||
|
||||
Reference in New Issue
Block a user