from services.faiss_service import FAISSService
from services.database_service import DatabaseService

class RAGSystem:
    def __init__(self):
        self.faiss = FAISSService()
        self.db = DatabaseService()

    def enrich_data(self, text):
        """Busca información previa relacionada y la usa para enriquecer el análisis."""
        indices, _ = self.faiss.search(text)
        previous_reports = self.db.get_reports()
        
        related_docs = [previous_reports[i]["content"] for i in indices if i < len(previous_reports)]
        return "\n".join(related_docs) if related_docs else "No se encontró información previa relevante."
