from __future__ import annotations

import json
import logging

from app.modules.rag.intent_router_v2.models import ConversationState, IntentRouterResult, RepoContext

LOGGER = logging.getLogger(__name__)


class IntentRouterLogger:
    def log_request(self, user_query: str, conversation_state: ConversationState, repo_context: RepoContext) -> None:
        LOGGER.warning(
            "intent router v2 request: turn=%s active_intent=%s user_query=%s languages=%s domains=%s",
            conversation_state.turn_index + 1,
            conversation_state.active_intent,
            " ".join((user_query or "").split()),
            repo_context.languages,
            repo_context.available_domains,
        )

    def log_result(self, result: IntentRouterResult) -> None:
        payload = json.dumps(result.model_dump(), ensure_ascii=False)
        LOGGER.warning("intent router v2 result: %s", payload)
