From 9adc0ade71fa70edfe91d956e0803196996ddfe1 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Mon, 14 Oct 2024 14:37:44 +0000 Subject: [PATCH] change import order --- crazy_functions/Rag_Interface.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crazy_functions/Rag_Interface.py b/crazy_functions/Rag_Interface.py index 33175df0..7f43f7d1 100644 --- a/crazy_functions/Rag_Interface.py +++ b/crazy_functions/Rag_Interface.py @@ -1,11 +1,9 @@ import os,glob from typing import List -from llama_index.core import Document from shared_utils.fastapi_server import validate_path_safety from toolbox import report_exception -from crazy_functions.rag_fns.rag_file_support import extract_text, supports_format from toolbox import CatchException, update_ui, get_conf, get_log_folder, update_ui_lastest_msg from crazy_functions.crazy_utils import input_clipping from crazy_functions.crazy_utils import request_gpt_model_in_new_thread_with_ui_alive @@ -20,10 +18,11 @@ def handle_document_upload(files: List[str], llm_kwargs, plugin_kwargs, chatbot, """ Handles document uploads by extracting text and adding it to the vector store. """ + from llama_index.core import Document + from crazy_functions.rag_fns.rag_file_support import extract_text, supports_format user_name = chatbot.get_user() checkpoint_dir = get_log_folder(user_name, plugin_name='experimental_rag') - for file_path in files: try: validate_path_safety(file_path, user_name) @@ -42,6 +41,8 @@ def handle_document_upload(files: List[str], llm_kwargs, plugin_kwargs, chatbot, yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 + + # Main Q&A function with document upload support @CatchException def Rag问答(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, user_request):