# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Union, Iterable
from typing_extensions import Required, TypeAlias, TypedDict

from ..s3_data_source_config_param import S3DataSourceConfigParam
from ..slack_data_source_config_param import SlackDataSourceConfigParam
from ..local_chunks_source_config_param import LocalChunksSourceConfigParam
from ..s3_data_source_auth_config_param import S3DataSourceAuthConfigParam
from ..confluence_data_source_config_param import ConfluenceDataSourceConfigParam
from ..slack_data_source_auth_config_param import SlackDataSourceAuthConfigParam
from ..share_point_data_source_config_param import SharePointDataSourceConfigParam
from ..token_chunking_strategy_config_param import TokenChunkingStrategyConfigParam
from ..custom_chunking_strategy_config_param import CustomChunkingStrategyConfigParam
from ..google_drive_data_source_config_param import GoogleDriveDataSourceConfigParam
from ..character_chunking_strategy_config_param import CharacterChunkingStrategyConfigParam
from ..confluence_data_source_auth_config_param import ConfluenceDataSourceAuthConfigParam
from ..share_point_data_source_auth_config_param import SharePointDataSourceAuthConfigParam
from ..google_drive_data_source_auth_config_param import GoogleDriveDataSourceAuthConfigParam
from ..azure_blob_storage_data_source_config_param import AzureBlobStorageDataSourceConfigParam
from ..azure_blob_storage_data_source_auth_config_param import AzureBlobStorageDataSourceAuthConfigParam

__all__ = [
    "UploadCreateParams",
    "CreateKnowledgeBaseV2UploadFromDataSourceRequest",
    "CreateKnowledgeBaseV2UploadFromDataSourceRequestDataSourceConfig",
    "CreateKnowledgeBaseV2UploadFromDataSourceRequestChunkingStrategyConfig",
    "CreateKnowledgeBaseV2UploadFromDataSourceRequestDataSourceAuthConfig",
    "CreateKnowledgeBaseV2UploadFromLocalChunksRequest",
    "CreateKnowledgeBaseV2UploadFromLocalChunksRequestChunk",
    "CreateKnowledgeBaseV2UploadFromDataSourceIDRequest",
    "CreateKnowledgeBaseV2UploadFromDataSourceIDRequestChunkingStrategyConfig",
]


class CreateKnowledgeBaseV2UploadFromDataSourceRequest(TypedDict, total=False):
    data_source_config: Required[CreateKnowledgeBaseV2UploadFromDataSourceRequestDataSourceConfig]
    """Configuration for the data source which describes where to find the data."""

    chunking_strategy_config: CreateKnowledgeBaseV2UploadFromDataSourceRequestChunkingStrategyConfig
    """Configuration for the chunking strategy which describes how to chunk the data."""

    data_source_auth_config: CreateKnowledgeBaseV2UploadFromDataSourceRequestDataSourceAuthConfig
    """
    Configuration for the data source which describes how to authenticate to the
    data source.
    """

    force_reupload: bool
    """Force reingest, regardless the change of the source file."""


CreateKnowledgeBaseV2UploadFromDataSourceRequestDataSourceConfig: TypeAlias = Union[
    S3DataSourceConfigParam,
    SharePointDataSourceConfigParam,
    GoogleDriveDataSourceConfigParam,
    AzureBlobStorageDataSourceConfigParam,
    ConfluenceDataSourceConfigParam,
    SlackDataSourceConfigParam,
]

CreateKnowledgeBaseV2UploadFromDataSourceRequestChunkingStrategyConfig: TypeAlias = Union[
    CharacterChunkingStrategyConfigParam, TokenChunkingStrategyConfigParam, CustomChunkingStrategyConfigParam
]

CreateKnowledgeBaseV2UploadFromDataSourceRequestDataSourceAuthConfig: TypeAlias = Union[
    SharePointDataSourceAuthConfigParam,
    AzureBlobStorageDataSourceAuthConfigParam,
    GoogleDriveDataSourceAuthConfigParam,
    S3DataSourceAuthConfigParam,
    ConfluenceDataSourceAuthConfigParam,
    SlackDataSourceAuthConfigParam,
]


class CreateKnowledgeBaseV2UploadFromLocalChunksRequest(TypedDict, total=False):
    data_source_config: Required[LocalChunksSourceConfigParam]
    """Configuration for the data source which describes where to find the data."""

    chunks: Iterable[CreateKnowledgeBaseV2UploadFromLocalChunksRequestChunk]
    """List of chunks."""

    force_reupload: bool
    """Force reingest, regardless the change of the source file."""


class CreateKnowledgeBaseV2UploadFromLocalChunksRequestChunk(TypedDict, total=False):
    chunk_position: Required[int]
    """Position of the chunk in the artifact."""

    text: Required[str]
    """Associated text of the chunk."""

    metadata: object
    """Additional metadata associated with the chunk."""


class CreateKnowledgeBaseV2UploadFromDataSourceIDRequest(TypedDict, total=False):
    chunking_strategy_config: Required[CreateKnowledgeBaseV2UploadFromDataSourceIDRequestChunkingStrategyConfig]
    """Configuration for the chunking strategy which describes how to chunk the data."""

    data_source_id: Required[str]
    """Id of the data source to fetch."""

    force_reupload: bool
    """Force reingest, regardless the change of the source file."""


CreateKnowledgeBaseV2UploadFromDataSourceIDRequestChunkingStrategyConfig: TypeAlias = Union[
    CharacterChunkingStrategyConfigParam, TokenChunkingStrategyConfigParam, CustomChunkingStrategyConfigParam
]

UploadCreateParams: TypeAlias = Union[
    CreateKnowledgeBaseV2UploadFromDataSourceRequest,
    CreateKnowledgeBaseV2UploadFromLocalChunksRequest,
    CreateKnowledgeBaseV2UploadFromDataSourceIDRequest,
]
