Редактировать rag_orchestrator.py
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
|
# ============================================================
|
||||||
|
# rag/rag_orchestrator.py
|
||||||
|
# Полная версия с поддержкой ToolHandler
|
||||||
|
# ============================================================
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Главный оркестратор RAG-пайплайна (фасад).
|
Главный оркестратор RAG-пайплайна (фасад).
|
||||||
Координирует работу менеджеров: HistoryManager, IntentRouter, QueryProcessor, IndexingManager.
|
Координирует работу менеджеров: HistoryManager, IntentRouter, QueryProcessor, IndexingManager.
|
||||||
|
Добавлена поддержка ToolHandler для ReAct.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@@ -20,6 +25,7 @@ from .indexing_manager import IndexingManager
|
|||||||
from .functions.intent_classify import classify_intent
|
from .functions.intent_classify import classify_intent
|
||||||
from .utils.text_utils import count_tokens
|
from .utils.text_utils import count_tokens
|
||||||
from .config_models import AppConfig
|
from .config_models import AppConfig
|
||||||
|
from .functions.tools import ToolHandler
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -39,7 +45,8 @@ class RAGOrchestrator:
|
|||||||
giga: GigaClient,
|
giga: GigaClient,
|
||||||
files: FileService,
|
files: FileService,
|
||||||
config: AppConfig,
|
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.db = db
|
||||||
self.qdrant = qdrant
|
self.qdrant = qdrant
|
||||||
@@ -49,6 +56,7 @@ class RAGOrchestrator:
|
|||||||
self.files = files
|
self.files = files
|
||||||
self.config = config
|
self.config = config
|
||||||
self.default_prompts = default_prompts or {}
|
self.default_prompts = default_prompts or {}
|
||||||
|
self.tool_handler = tool_handler
|
||||||
|
|
||||||
# Инициализация менеджеров
|
# Инициализация менеджеров
|
||||||
self.history_manager = HistoryManager(
|
self.history_manager = HistoryManager(
|
||||||
@@ -70,7 +78,9 @@ class RAGOrchestrator:
|
|||||||
giga=giga,
|
giga=giga,
|
||||||
kb=kb,
|
kb=kb,
|
||||||
config=config,
|
config=config,
|
||||||
default_prompts=self.default_prompts
|
default_prompts=self.default_prompts,
|
||||||
|
agent_coordinator=None, # будет установлен позже, если включены агенты
|
||||||
|
tool_handler=tool_handler
|
||||||
)
|
)
|
||||||
|
|
||||||
self.indexing_manager = IndexingManager(
|
self.indexing_manager = IndexingManager(
|
||||||
@@ -82,6 +92,11 @@ class RAGOrchestrator:
|
|||||||
|
|
||||||
logger.info("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(
|
def _prepare_prompt_parts(
|
||||||
self,
|
self,
|
||||||
synthesis_template: str,
|
synthesis_template: str,
|
||||||
|
|||||||
Reference in New Issue
Block a user