mirror of
https://github.com/open-webui/open-webui
synced 2025-04-25 16:49:46 +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
|
file_id: str
|
||||||
collection_name: Optional[str] = None
|
collection_name: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
@app.post("/process/doc")
|
@app.post("/process/file")
|
||||||
def process_doc(
|
def process_file(
|
||||||
form_data: ProcessDocForm,
|
form_data: ProcessFileForm,
|
||||||
user=Depends(get_verified_user),
|
user=Depends(get_verified_user),
|
||||||
):
|
):
|
||||||
try:
|
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")
|
MILVUS_URI = os.environ.get("MILVUS_URI", f"{DATA_DIR}/vector_db/milvus.db")
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# RAG
|
# Information Retrieval (RAG)
|
||||||
####################################
|
####################################
|
||||||
|
|
||||||
# RAG Content Extraction
|
# RAG Content Extraction
|
||||||
|
@ -170,10 +170,10 @@ export const updateQuerySettings = async (token: string, settings: QuerySettings
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const processDocToVectorDB = async (token: string, file_id: string) => {
|
export const processFile = async (token: string, file_id: string) => {
|
||||||
let error = null;
|
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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
@ -52,7 +52,7 @@
|
|||||||
updateChatById
|
updateChatById
|
||||||
} from '$lib/apis/chats';
|
} from '$lib/apis/chats';
|
||||||
import { generateOpenAIChatCompletion } from '$lib/apis/openai';
|
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 { createOpenAITextStream } from '$lib/apis/streaming';
|
||||||
import { queryMemory } from '$lib/apis/memories';
|
import { queryMemory } from '$lib/apis/memories';
|
||||||
import { getAndUpdateUserLocation, getUserSettings } from '$lib/apis/users';
|
import { getAndUpdateUserLocation, getUserSettings } from '$lib/apis/users';
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
import { blobToFile, findWordIndices } from '$lib/utils';
|
import { blobToFile, findWordIndices } from '$lib/utils';
|
||||||
|
|
||||||
import { transcribeAudio } from '$lib/apis/audio';
|
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 { uploadFile } from '$lib/apis/files';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -158,7 +159,7 @@
|
|||||||
|
|
||||||
const processFileItem = async (fileItem) => {
|
const processFileItem = async (fileItem) => {
|
||||||
try {
|
try {
|
||||||
const res = await processDocToVectorDB(localStorage.token, fileItem.id);
|
const res = await processFile(localStorage.token, fileItem.id);
|
||||||
if (res) {
|
if (res) {
|
||||||
fileItem.status = 'processed';
|
fileItem.status = 'processed';
|
||||||
fileItem.collection_name = res.collection_name;
|
fileItem.collection_name = res.collection_name;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import { createNewDoc, deleteDocByName, getDocs } from '$lib/apis/documents';
|
import { createNewDoc, deleteDocByName, getDocs } from '$lib/apis/documents';
|
||||||
|
|
||||||
import { SUPPORTED_FILE_TYPE, SUPPORTED_FILE_EXTENSIONS } from '$lib/constants';
|
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 { blobToFile, transformFileName } from '$lib/utils';
|
||||||
|
|
||||||
import Checkbox from '$lib/components/common/Checkbox.svelte';
|
import Checkbox from '$lib/components/common/Checkbox.svelte';
|
||||||
@ -74,7 +74,7 @@
|
|||||||
return null;
|
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);
|
toast.error(error);
|
||||||
return null;
|
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) => {
|
export const RAGTemplate = async (token: string, context: string, query: string) => {
|
||||||
let template = await getRAGTemplate(token).catch(() => {
|
let template = await getRAGTemplate(token).catch(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user