Update 6 files
- /rag/history_manager.py - /rag/query_processor.py - /rag/rag_orchestrator.py - /rag/rag_api.py - /rag/rag_server.py - /rag/__init__.py
This commit is contained in:
@@ -8,18 +8,19 @@
|
||||
import logging
|
||||
from typing import Optional, Dict, List, Any
|
||||
|
||||
from core.services.postgres_service import PostgresService
|
||||
from core.services.qdrant_service import QdrantService
|
||||
from core.services.embedding_service import EmbeddingService
|
||||
from core.services.kb_service import KBService
|
||||
from core.services.giga_client import GigaClient
|
||||
from core.services.file_service import FileService
|
||||
from core.history_manager import HistoryManager
|
||||
from core.intent_router import IntentRouter
|
||||
from core.query_processor import QueryProcessor
|
||||
from core.indexing_manager import IndexingManager
|
||||
from core.functions.intent_classify import classify_intent
|
||||
from core.utils.text_utils import count_tokens
|
||||
from rag.services.postgres_service import PostgresService
|
||||
from rag.services.qdrant_service import QdrantService
|
||||
from rag.services.embedding_service import EmbeddingService
|
||||
from rag.services.kb_service import KBService
|
||||
from rag.services.giga_client import GigaClient
|
||||
from rag.services.file_service import FileService
|
||||
from rag.history_manager import HistoryManager
|
||||
from rag.intent_router import IntentRouter
|
||||
from rag.query_processor import QueryProcessor
|
||||
from rag.indexing_manager import IndexingManager
|
||||
from rag.functions.intent_classify import classify_intent
|
||||
from rag.utils.text_utils import count_tokens
|
||||
from rag.config_models import AppConfig
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -39,7 +40,7 @@ class RAGOrchestrator:
|
||||
kb: KBService,
|
||||
giga: GigaClient,
|
||||
files: FileService,
|
||||
config,
|
||||
config: AppConfig,
|
||||
default_prompts: Optional[Dict[str, str]] = None
|
||||
):
|
||||
"""
|
||||
@@ -52,7 +53,7 @@ class RAGOrchestrator:
|
||||
kb: сервис базы знаний
|
||||
giga: клиент GigaChat
|
||||
files: сервис файлов
|
||||
config: объект конфигурации (BotConfig)
|
||||
config: объект конфигурации (AppConfig)
|
||||
default_prompts: словарь промптов по умолчанию
|
||||
"""
|
||||
self.db = db
|
||||
@@ -182,9 +183,9 @@ class RAGOrchestrator:
|
||||
system_prompt = prompts.get('system', None)
|
||||
|
||||
# 2. Расчёт лимитов токенов
|
||||
max_model_tokens = getattr(self.config, 'max_model_tokens', 8192)
|
||||
reserved_for_answer = getattr(self.config, 'reserved_for_answer_tokens', 1000)
|
||||
reserved_for_overhead = getattr(self.config, 'reserved_for_overhead_tokens', 200)
|
||||
max_model_tokens = self.config.rag.max_model_tokens
|
||||
reserved_for_answer = self.config.rag.reserved_for_answer_tokens
|
||||
reserved_for_overhead = self.config.rag.reserved_for_overhead_tokens
|
||||
|
||||
token_info = self._prepare_prompt_parts(
|
||||
synthesis_template=synthesis_template,
|
||||
@@ -210,7 +211,7 @@ class RAGOrchestrator:
|
||||
|
||||
# 5. Классификация намерений
|
||||
intent = intent_override
|
||||
if intent is None and getattr(self.config, 'enable_intent_classification', True):
|
||||
if intent is None and self.config.features.enable_intent_classification:
|
||||
intent_prompt = prompts.get('intent', '')
|
||||
if intent_prompt:
|
||||
intent = await classify_intent(
|
||||
@@ -225,7 +226,7 @@ class RAGOrchestrator:
|
||||
intent = intent or "GENERAL"
|
||||
|
||||
# 6. Принудительная установка SURGICAL по ключевым словам
|
||||
keywords = getattr(self.config, 'surgical_keywords', [])
|
||||
keywords = self.config.features.surgical_keywords
|
||||
if any(kw in query.lower() for kw in keywords) and last_file_path:
|
||||
intent = "SURGICAL"
|
||||
logger.info(f"Принудительный Intent: SURGICAL (есть файл и ключевые слова)")
|
||||
|
||||
Reference in New Issue
Block a user