From 14c049e1f3482836b12d1c343b942f659f72dc96 Mon Sep 17 00:00:00 2001 From: Markov Andrey Date: Tue, 30 Jun 2026 23:05:34 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20rag=5Forchestrator.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rag/rag_orchestrator.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/rag/rag_orchestrator.py b/rag/rag_orchestrator.py index 4f42273..9479f4f 100644 --- a/rag/rag_orchestrator.py +++ b/rag/rag_orchestrator.py @@ -1,7 +1,12 @@ +# ============================================================ +# rag/rag_orchestrator.py +# Полная версия с поддержкой ToolHandler +# ============================================================ # -*- coding: utf-8 -*- """ Главный оркестратор RAG-пайплайна (фасад). Координирует работу менеджеров: HistoryManager, IntentRouter, QueryProcessor, IndexingManager. +Добавлена поддержка ToolHandler для ReAct. """ import logging @@ -20,6 +25,7 @@ from .indexing_manager import IndexingManager from .functions.intent_classify import classify_intent from .utils.text_utils import count_tokens from .config_models import AppConfig +from .functions.tools import ToolHandler logger = logging.getLogger(__name__) @@ -39,7 +45,8 @@ class RAGOrchestrator: giga: GigaClient, files: FileService, config: AppConfig, - default_prompts: Optional[Dict[str, str]] = None + default_prompts: Optional[Dict[str, str]] = None, + tool_handler: Optional[ToolHandler] = None, ): self.db = db self.qdrant = qdrant @@ -49,6 +56,7 @@ class RAGOrchestrator: self.files = files self.config = config self.default_prompts = default_prompts or {} + self.tool_handler = tool_handler # Инициализация менеджеров self.history_manager = HistoryManager( @@ -70,7 +78,9 @@ class RAGOrchestrator: giga=giga, kb=kb, config=config, - default_prompts=self.default_prompts + default_prompts=self.default_prompts, + agent_coordinator=None, # будет установлен позже, если включены агенты + tool_handler=tool_handler ) self.indexing_manager = IndexingManager( @@ -82,6 +92,11 @@ class RAGOrchestrator: logger.info("RAGOrchestrator инициализирован с менеджерами") + def set_agent_coordinator(self, agent_coordinator): + """Устанавливает координатор агентов в QueryProcessor.""" + self.query_processor.agent_coordinator = agent_coordinator + logger.info("AgentCoordinator передан в QueryProcessor") + def _prepare_prompt_parts( self, synthesis_template: str,