from __future__ import annotations

from sqlalchemy.orm import Session

from app.models.chat import ChatMessage
from app.models.user import User
from app.services.knowledge_agent_service import KnowledgeAgentService
from app.services.rag_service import RagResult


class AsyncRagService:
    @staticmethod
    async def build_result(
        db: Session,
        user: User,
        question: str,
        history: list[ChatMessage] | None = None,
        session_summary: str | None = None,
        summary_up_to_message_id: int | None = None,
        session_id: int | None = None,
        context_trace: list[dict] | None = None,
        growth_context: str | None = None,
        topic_context: str | None = None,
        product_context: str | None = None,
    ) -> RagResult:
        return await KnowledgeAgentService.build_result(
            db,
            question=question,
            history=history,
            session_summary=session_summary,
            summary_up_to_message_id=summary_up_to_message_id,
            session_id=session_id,
            user_id=user.id,
            context_trace=context_trace,
            growth_context=growth_context,
            topic_context=topic_context,
            product_context=product_context,
        )
