DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
Revert knowledge base plugin integration - keep original RAG-Anything flow
Tushar Khatrif7711993814e
diff --git a/src/knowledge/add_documents.py b/src/knowledge/add_documents.pyindex 14566e7bc..0465480c8 100644--- a/src/knowledge/add_documents.py+++ b/src/knowledge/add_documents.py@@ -29,7 +29,6 @@ from lightrag.utils import EmbeddingFuncfrom raganything import RAGAnything, RAGAnythingConfigfrom src.core.core import get_embedding_config, get_llm_config-from src.tools.rag_tool import initialize_rag as plugin_initialize_rag, get_current_providerload_dotenv(dotenv_path=".env", override=False)@@ -140,17 +139,11 @@ class DocumentAdder:logger.warning("No new files to process")return None- # Get current RAG provider- rag_provider = get_current_provider()- logger.info(f"\nProcessing {len(new_files)} new documents with {rag_provider}...")+ logger.info(f"\nProcessing {len(new_files)} new documents...")- # Use RAG-Anything for extraction, then plugin for indexing- extraction_dir = self.rag_storage_dir / "_extraction"- extraction_dir.mkdir(exist_ok=True)-- # Create RAGAnything configuration for extraction+ # Create RAGAnything configurationconfig = RAGAnythingConfig(- working_dir=str(extraction_dir),+ working_dir=str(self.rag_storage_dir),enable_image_processing=True,enable_table_processing=True,enable_equation_processing=True,@@ -323,56 +316,6 @@ class DocumentAdder:# Fix structureawait self.fix_structure()- # Now add extracted content to the selected RAG plugin- logger.info(f"\nAdding content to {rag_provider} RAG system...")- try:- # Collect extracted text content from processed files- new_documents = []- for doc_file in processed_files:- content_file = self.content_list_dir / f"{doc_file.stem}.json"- if content_file.exists():- try:- with open(content_file, 'r', encoding='utf-8') as f:- content_data = json.load(f)- # Extract text from content list- if isinstance(content_data, list):- for item in content_data:- if isinstance(item, dict) and 'text' in item:- new_documents.append(item['text'])- elif isinstance(item, str):- new_documents.append(item)- elif isinstance(content_data, str):- new_documents.append(content_data)- except Exception as e:- logger.warning(f"Could not read {content_file.name}: {e}")-- # Also read .txt or .md files directly- if doc_file.suffix.lower() in ['.txt', '.md']:- try:- new_documents.append(doc_file.read_text(encoding='utf-8'))- except Exception as e:- logger.warning(f"Could not read {doc_file.name}: {e}")-- if new_documents:- logger.info(f"Adding {len(new_documents)} text chunks to {rag_provider} index...")- success = await plugin_initialize_rag(- kb_name=self.kb_name,- documents=new_documents,- provider=rag_provider- )-- if success:- logger.success(f"✓ Content added to {rag_provider} index successfully")- else:- logger.error(f"✗ Failed to add content to {rag_provider} index")- else:- logger.warning("No text content extracted for RAG indexing")-- except Exception as e:- logger.error(f"Error adding to RAG plugin: {e}")- import traceback- logger.error(traceback.format_exc())-logger.info("\n✓ Document processing completed!")return processed_filesdiff --git a/src/knowledge/initializer.py b/src/knowledge/initializer.pyindex 768b7ab92..6ffa0bd86 100644--- a/src/knowledge/initializer.py+++ b/src/knowledge/initializer.py@@ -31,7 +31,6 @@ from lightrag.utils import EmbeddingFuncfrom raganything import RAGAnything, RAGAnythingConfigfrom src.core.core import get_embedding_config, get_llm_config-from src.tools.rag_tool import initialize_rag as plugin_initialize_rag, get_current_providerload_dotenv(dotenv_path=".env", override=False)@@ -159,14 +158,11 @@ class KnowledgeBaseInitializer:return copied_filesasync def process_documents(self):- """Process documents using configured RAG provider"""- # Get current RAG provider- rag_provider = get_current_provider()- logger.info(f"Processing documents with RAG provider: {rag_provider}")-+ """Process documents using RAG-Anything"""+ logger.info("Processing documents with RAG-Anything...")self.progress_tracker.update(ProgressStage.PROCESSING_DOCUMENTS,- f"Starting to process documents with {rag_provider}...",+ "Starting to process documents...",current=0,total=0,)@@ -186,20 +182,14 @@ class KnowledgeBaseInitializer:logger.info(f"Found {len(doc_files)} document(s) to process")self.progress_tracker.update(ProgressStage.PROCESSING_DOCUMENTS,- f"Found {len(doc_files)} documents, starting to process with {rag_provider}...",+ f"Found {len(doc_files)} documents, starting to process...",current=0,total=len(doc_files),)- # Use RAG-Anything for document extraction (handles PDF, images, tables)- # Then feed extracted content to the selected RAG plugin-- # Create RAGAnything configuration for extraction only- extraction_dir = self.rag_storage_dir / "_extraction"- extraction_dir.mkdir(exist_ok=True)-+ # Create RAGAnything configurationconfig = RAGAnythingConfig(- working_dir=str(extraction_dir),+ working_dir=str(self.rag_storage_dir),enable_image_processing=True,enable_table_processing=True,enable_equation_processing=True,@@ -371,62 +361,6 @@ class KnowledgeBaseInitializer:# Fix structure: flatten nested content_list directoriesawait self.fix_structure()- # Now initialize the selected RAG plugin with extracted content- logger.info(f"\nInitializing {rag_provider} RAG system...")- self.progress_tracker.update(- ProgressStage.PROCESSING_DOCUMENTS,- f"Building {rag_provider} index...",- current=len(doc_files),- total=len(doc_files),- )-- try:- # Collect all extracted text content- all_documents = []- for content_file in self.content_list_dir.glob("*.json"):- try:- with open(content_file, 'r', encoding='utf-8') as f:- content_data = json.load(f)- # Extract text from content list- if isinstance(content_data, list):- for item in content_data:- if isinstance(item, dict) and 'text' in item:- all_documents.append(item['text'])- elif isinstance(item, str):- all_documents.append(item)- elif isinstance(content_data, str):- all_documents.append(content_data)- except Exception as e:- logger.warning(f"Could not read {content_file.name}: {e}")-- # Also read any .txt or .md files directly- for doc_file in doc_files:- if doc_file.suffix.lower() in ['.txt', '.md']:- try:- all_documents.append(doc_file.read_text(encoding='utf-8'))- except Exception as e:- logger.warning(f"Could not read {doc_file.name}: {e}")-- if all_documents:- logger.info(f"Collected {len(all_documents)} text chunks for RAG indexing")- success = await plugin_initialize_rag(- kb_name=self.kb_name,- documents=all_documents,- provider=rag_provider- )-- if success:- logger.success(f"✓ {rag_provider} RAG index built successfully")- else:- logger.error(f"✗ Failed to build {rag_provider} RAG index")- else:- logger.warning("No text content extracted for RAG indexing")-- except Exception as e:- logger.error(f"Error initializing RAG plugin: {e}")- import traceback- logger.error(traceback.format_exc())-# Display statisticsawait self.display_statistics(rag)