Update 5 files
- /rag/config_models.py - /rag/utils/config_loader.py - /rag/rag_orchestrator.py - /rag/rag_server.py - /rag/rag_api.py
This commit is contained in:
@@ -8,19 +8,19 @@
|
||||
import logging
|
||||
from typing import Optional, Dict, List, Any
|
||||
|
||||
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
|
||||
from .services.postgres_service import PostgresService
|
||||
from .services.qdrant_service import QdrantService
|
||||
from .services.embedding_service import EmbeddingService
|
||||
from .services.kb_service import KBService
|
||||
from .services.giga_client import GigaClient
|
||||
from .services.file_service import FileService
|
||||
from .history_manager import HistoryManager
|
||||
from .intent_router import IntentRouter
|
||||
from .query_processor import QueryProcessor
|
||||
from .indexing_manager import IndexingManager
|
||||
from .functions.intent_classify import classify_intent
|
||||
from .utils.text_utils import count_tokens
|
||||
from .config_models import AppConfig
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -183,9 +183,9 @@ class RAGOrchestrator:
|
||||
system_prompt = prompts.get('system', None)
|
||||
|
||||
# 2. Расчёт лимитов токенов
|
||||
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
|
||||
max_model_tokens = self.config.max_model_tokens
|
||||
reserved_for_answer = self.config.reserved_for_answer_tokens
|
||||
reserved_for_overhead = self.config.reserved_for_overhead_tokens
|
||||
|
||||
token_info = self._prepare_prompt_parts(
|
||||
synthesis_template=synthesis_template,
|
||||
@@ -211,7 +211,7 @@ class RAGOrchestrator:
|
||||
|
||||
# 5. Классификация намерений
|
||||
intent = intent_override
|
||||
if intent is None and self.config.features.enable_intent_classification:
|
||||
if intent is None and self.config.enable_intent_classification:
|
||||
intent_prompt = prompts.get('intent', '')
|
||||
if intent_prompt:
|
||||
intent = await classify_intent(
|
||||
@@ -226,7 +226,7 @@ class RAGOrchestrator:
|
||||
intent = intent or "GENERAL"
|
||||
|
||||
# 6. Принудительная установка SURGICAL по ключевым словам
|
||||
keywords = self.config.features.surgical_keywords
|
||||
keywords = self.config.surgical_keywords
|
||||
if any(kw in query.lower() for kw in keywords) and last_file_path:
|
||||
intent = "SURGICAL"
|
||||
logger.info(f"Принудительный Intent: SURGICAL (есть файл и ключевые слова)")
|
||||
@@ -255,7 +255,6 @@ class RAGOrchestrator:
|
||||
sources = router_result.get("sources", [])
|
||||
else:
|
||||
# Обычный RAG-пайплайн (GENERAL, FACT, PROCEDURE, COMPARISON, CALCULATION)
|
||||
# Вычисляем, сколько токенов осталось для контекста после истории
|
||||
history_tokens = sum(count_tokens(msg['content']) for msg in formatted_history)
|
||||
available_for_context = available_for_history_and_context - history_tokens
|
||||
available_for_context = max(available_for_context, 0)
|
||||
|
||||
Reference in New Issue
Block a user