from __future__ import annotations

from abc import ABC, abstractmethod
from typing import AsyncGenerator

from fastapi_modules.fastapi_leaudit.domian.Dto.ragChatDto import (
    RagConversationRenameDTO,
    RagMessageFeedbackDTO,
    RagStopMessageDTO,
)
from fastapi_modules.fastapi_leaudit.domian.vo.ragChatVo import (
    RagAppParametersVO,
    RagChatAppListVO,
    RagChatAppVO,
    RagConversationPageVO,
    RagConversationRenameVO,
    RagMessagePageVO,
    RagOperationResultVO,
)


class IRagChatService(ABC):
    @abstractmethod
    async def GetApps(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagChatAppListVO: ...

    @abstractmethod
    async def GetDefaultApp(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagChatAppVO | None: ...

    @abstractmethod
    async def SendMessage(
        self,
        CurrentUserId: int,
        UserName: str,
        UserArea: str | None,
        UserRole: str | None,
        Query: str,
        ConversationId: str | None,
        AppId: int | None,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> AsyncGenerator[bytes, None]: ...

    @abstractmethod
    async def GetConversations(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        AppId: int | None,
        Page: int,
        PageSize: int,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagConversationPageVO: ...

    @abstractmethod
    async def GetConversationMessages(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        ConversationId: str,
        Page: int,
        PageSize: int,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagMessagePageVO: ...

    @abstractmethod
    async def RenameConversation(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        ConversationId: str,
        Body: RagConversationRenameDTO,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagConversationRenameVO: ...

    @abstractmethod
    async def DeleteConversation(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        ConversationId: str,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagOperationResultVO: ...

    @abstractmethod
    async def UpdateFeedback(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        MessageId: str,
        Body: RagMessageFeedbackDTO,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagOperationResultVO: ...

    @abstractmethod
    async def StopMessage(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        MessageId: str,
        Body: RagStopMessageDTO | None = None,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagOperationResultVO: ...

    @abstractmethod
    async def GetAppParameters(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        AppId: int | None,
        TenantCode: str | None = None,
        TenantName: str | None = None,
    ) -> RagAppParametersVO: ...
