mirror of
https://github.com/open-webui/open-webui
synced 2025-01-18 00:30:51 +00:00
refac
This commit is contained in:
parent
5b7cf88915
commit
a52e8cd537
@ -1340,14 +1340,14 @@ def store_doc(
|
||||
)
|
||||
|
||||
|
||||
class ProcessDocForm(BaseModel):
|
||||
class ProcessFileForm(BaseModel):
|
||||
file_id: str
|
||||
collection_name: Optional[str] = None
|
||||
|
||||
|
||||
@app.post("/process/doc")
|
||||
def process_doc(
|
||||
form_data: ProcessDocForm,
|
||||
@app.post("/process/file")
|
||||
def process_file(
|
||||
form_data: ProcessFileForm,
|
||||
user=Depends(get_verified_user),
|
||||
):
|
||||
try:
|
||||
|
@ -921,7 +921,7 @@ CHROMA_HTTP_SSL = os.environ.get("CHROMA_HTTP_SSL", "false").lower() == "true"
|
||||
MILVUS_URI = os.environ.get("MILVUS_URI", f"{DATA_DIR}/vector_db/milvus.db")
|
||||
|
||||
####################################
|
||||
# RAG
|
||||
# Information Retrieval (RAG)
|
||||
####################################
|
||||
|
||||
# RAG Content Extraction
|
||||
|
@ -170,10 +170,10 @@ export const updateQuerySettings = async (token: string, settings: QuerySettings
|
||||
return res;
|
||||
};
|
||||
|
||||
export const processDocToVectorDB = async (token: string, file_id: string) => {
|
||||
export const processFile = async (token: string, file_id: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${RAG_API_BASE_URL}/process/doc`, {
|
||||
const res = await fetch(`${RAG_API_BASE_URL}/process/file`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
@ -52,7 +52,7 @@
|
||||
updateChatById
|
||||
} from '$lib/apis/chats';
|
||||
import { generateOpenAIChatCompletion } from '$lib/apis/openai';
|
||||
import { runWebSearch } from '$lib/apis/rag';
|
||||
import { runWebSearch } from '$lib/apis/retrieval';
|
||||
import { createOpenAITextStream } from '$lib/apis/streaming';
|
||||
import { queryMemory } from '$lib/apis/memories';
|
||||
import { getAndUpdateUserLocation, getUserSettings } from '$lib/apis/users';
|
||||
|
@ -17,7 +17,8 @@
|
||||
import { blobToFile, findWordIndices } from '$lib/utils';
|
||||
|
||||
import { transcribeAudio } from '$lib/apis/audio';
|
||||
import { processDocToVectorDB } from '$lib/apis/rag';
|
||||
|
||||
import { processFile } from '$lib/apis/retrieval';
|
||||
import { uploadFile } from '$lib/apis/files';
|
||||
|
||||
import {
|
||||
@ -158,7 +159,7 @@
|
||||
|
||||
const processFileItem = async (fileItem) => {
|
||||
try {
|
||||
const res = await processDocToVectorDB(localStorage.token, fileItem.id);
|
||||
const res = await processFile(localStorage.token, fileItem.id);
|
||||
if (res) {
|
||||
fileItem.status = 'processed';
|
||||
fileItem.collection_name = res.collection_name;
|
||||
|
@ -8,7 +8,7 @@
|
||||
import { createNewDoc, deleteDocByName, getDocs } from '$lib/apis/documents';
|
||||
|
||||
import { SUPPORTED_FILE_TYPE, SUPPORTED_FILE_EXTENSIONS } from '$lib/constants';
|
||||
import { processDocToVectorDB, uploadDocToVectorDB } from '$lib/apis/rag';
|
||||
import { processFile } from '$lib/apis/rag';
|
||||
import { blobToFile, transformFileName } from '$lib/utils';
|
||||
|
||||
import Checkbox from '$lib/components/common/Checkbox.svelte';
|
||||
@ -74,7 +74,7 @@
|
||||
return null;
|
||||
});
|
||||
|
||||
const res = await processDocToVectorDB(localStorage.token, uploadedFile.id).catch((error) => {
|
||||
const res = await processFile(localStorage.token, uploadedFile.id).catch((error) => {
|
||||
toast.error(error);
|
||||
return null;
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getRAGTemplate } from '$lib/apis/rag';
|
||||
import { getRAGTemplate } from '$lib/apis/retrieval';
|
||||
|
||||
export const RAGTemplate = async (token: string, context: string, query: string) => {
|
||||
let template = await getRAGTemplate(token).catch(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user