from __future__ import annotations

from abc import ABC, abstractmethod

from fastapi_modules.fastapi_leaudit.domian.Dto.ragDatasetDto import RagDatasetUpdateDTO
from fastapi_modules.fastapi_leaudit.domian.vo.ragDatasetVo import (
    RagDatasetBatchDeleteResultVO,
    RagDatasetDetailVO,
    RagDatasetDocumentItemVO,
    RagDatasetDocumentPageVO,
    RagDatasetPageVO,
    RagDatasetRetrieveResponseVO,
    RagDatasetSegmentPageVO,
    RagDatasetUploadDocumentVO,
)
from fastapi_modules.fastapi_leaudit.domian.vo.ragChatVo import RagOperationResultVO


class IRagDatasetService(ABC):
    @abstractmethod
    async def GetAdminDatasets(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        Area: str | None,
        OnlyEnabled: bool | None,
        Page: int,
        PageSize: int,
    ) -> RagDatasetPageVO: ...

    @abstractmethod
    async def CreateAdminDataset(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        Body: dict,
    ) -> RagDatasetDetailVO: ...

    @abstractmethod
    async def UpdateAdminDataset(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        Body: dict,
    ) -> RagDatasetDetailVO | None: ...

    @abstractmethod
    async def DeleteAdminDataset(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
    ) -> RagOperationResultVO: ...

    @abstractmethod
    async def GetMyDatasets(self, CurrentUserId: int, UserArea: str | None, UserRole: str | None) -> RagDatasetPageVO: ...

    @abstractmethod
    async def GetDatasetDetail(self, CurrentUserId: int, UserArea: str | None, UserRole: str | None, DatasetId: int) -> RagDatasetDetailVO | None: ...

    @abstractmethod
    async def UpdateDataset(self, CurrentUserId: int, UserArea: str | None, UserRole: str | None, DatasetId: int, Body: RagDatasetUpdateDTO) -> RagDatasetDetailVO | None: ...

    @abstractmethod
    async def GetDatasetDocuments(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        Page: int,
        Limit: int,
        Keyword: str | None,
    ) -> RagDatasetDocumentPageVO: ...

    @abstractmethod
    async def GetDatasetDocumentDetail(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
    ) -> RagDatasetDocumentItemVO | None: ...

    @abstractmethod
    async def UploadDatasetDocument(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        FileName: str,
        ContentType: str | None,
        Content: bytes,
        ProcessConfig: dict | None,
    ) -> RagDatasetUploadDocumentVO: ...

    @abstractmethod
    async def GetDatasetDocumentSegments(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
        Page: int,
        Limit: int,
        Keyword: str | None,
    ) -> RagDatasetSegmentPageVO: ...

    @abstractmethod
    async def DeleteDatasetDocument(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
    ) -> RagOperationResultVO: ...

    @abstractmethod
    async def BatchDeleteDatasetDocuments(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentIds: list[int],
    ) -> RagDatasetBatchDeleteResultVO: ...

    @abstractmethod
    async def RetrieveDataset(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        Query: str,
        RetrievalModel: dict | None,
    ) -> RagDatasetRetrieveResponseVO: ...

    @abstractmethod
    async def GetDatasetDocumentIndexingStatus(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
    ) -> dict: ...

    @abstractmethod
    async def UpdateDatasetDocumentByFile(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
        FileName: str,
        ContentType: str | None,
        Content: bytes,
        ProcessConfig: dict | None,
    ) -> RagDatasetUploadDocumentVO: ...

    @abstractmethod
    async def BatchUpdateDatasetDocumentStatus(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentIds: list[int],
        Enabled: bool,
    ) -> RagOperationResultVO: ...

    @abstractmethod
    async def GetDatasetDocumentSegmentDetail(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
        SegmentId: str,
    ) -> RagDatasetSegmentItemVO | None: ...

    @abstractmethod
    async def UpdateDatasetDocumentSegment(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
        SegmentId: str,
        Body: dict,
    ) -> RagDatasetSegmentItemVO | None: ...

    @abstractmethod
    async def DeleteDatasetDocumentSegment(
        self,
        CurrentUserId: int,
        UserArea: str | None,
        UserRole: str | None,
        DatasetId: int,
        DocumentId: int,
        SegmentId: str,
    ) -> RagOperationResultVO: ...
