# SPDX-License-Identifier: Apache-2.0
# 
# Copyright (C) 2024 Acuvity, Inc.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Code generated by regolithe-python. DO NOT EDIT.
# Source: github.com/acuvity/regolithe-python (templates/model.py.tmpl)

from .elemental import ElementalModel
from .modality import Modality
from .textualdetection import TextualDetection
from pydantic import ConfigDict, Field
from typing import Dict, List, Optional


class Extraction(ElementalModel):
    """
    Represents the extracted information to log.

    Attributes:
        piis: The PIIs found during classification.
        annotations: Annotations attached to the extraction.
        categories: The categories are remapping of the modalities in a more human friendly way.
        confidentiality: The level of general confidentiality of the input.
        data: The data extracted.
        detections: The detections found while applying policies.
        exploits: The various exploits attempts.
        hash: The hash of the extraction.
        intent: The estimated intent embodied into the text.
        internal: If true, this extraction is for internal use only.
        keywords: The keywords found during classification.
        label: A means of distinguishing what was extracted, such as prompt, input file or code.
        languages: The language of the classification.
        lua_id: An internal field for lua code. it is ignored by the API.
        modalities: The modalities of data detected in the data.
        redactions: The redactions that has been performed.
        relevance: The level of general organization relevance of the input.
        secrets: The secrets found during classification.
        topics: The topic of the classification.
    """
    # there is a few things to know about elemental based models:
    # - they can never be strict
    # - we need to use enum values instead of their keys
    # - because of that we also need to use validate_default, otherwise the keys are used for enums on defaults
    # - we allow population by field name to make it more natural to use from python
    model_config = ConfigDict(
        strict=False,
        use_enum_values=True,
        validate_default=True,
        populate_by_name=True,
        extra="forbid",
    )

    # all spec fields
    piis: Optional[Dict[str, float]] = Field(
        None,
        alias="PIIs",
        description="The PIIs found during classification.",
    )
    annotations: Optional[Dict[str, str]] = Field(
        None,
        alias="annotations",
        description="Annotations attached to the extraction.",
    )
    categories: Optional[List[Modality]] = Field(
        None,
        alias="categories",
        description="The categories are remapping of the modalities in a more human friendly way.",
    )
    confidentiality: Optional[float] = Field(
        None,
        alias="confidentiality",
        description="The level of general confidentiality of the input.",
        examples=[0.900000],
    )
    data: Optional[str] = Field(
        None,
        alias="data",
        description="The data extracted.",
    )
    detections: Optional[List[TextualDetection]] = Field(
        None,
        alias="detections",
        description="The detections found while applying policies.",
    )
    exploits: Optional[Dict[str, float]] = Field(
        None,
        alias="exploits",
        description="The various exploits attempts.",
    )
    hash: Optional[str] = Field(
        None,
        alias="hash",
        description="The hash of the extraction.",
    )
    intent: Optional[Dict[str, float]] = Field(
        None,
        alias="intent",
        description="The estimated intent embodied into the text.",
    )
    internal: Optional[bool] = Field(
        None,
        alias="internal",
        description="If true, this extraction is for internal use only.",
    )
    keywords: Optional[Dict[str, float]] = Field(
        None,
        alias="keywords",
        description="The keywords found during classification.",
    )
    label: Optional[str] = Field(
        None,
        alias="label",
        description="A means of distinguishing what was extracted, such as prompt, input file or code.",
    )
    languages: Optional[Dict[str, float]] = Field(
        None,
        alias="languages",
        description="The language of the classification.",
    )
    lua_id: Optional[str] = Field(
        None,
        alias="luaID",
        description="An internal field for lua code. it is ignored by the API.",
    )
    modalities: Optional[List[Modality]] = Field(
        None,
        alias="modalities",
        description="The modalities of data detected in the data.",
    )
    redactions: Optional[List[TextualDetection]] = Field(
        None,
        alias="redactions",
        description="The redactions that has been performed.",
    )
    relevance: Optional[float] = Field(
        None,
        alias="relevance",
        description="The level of general organization relevance of the input.",
        examples=[0.900000],
    )
    secrets: Optional[Dict[str, float]] = Field(
        None,
        alias="secrets",
        description="The secrets found during classification.",
    )
    topics: Optional[Dict[str, float]] = Field(
        None,
        alias="topics",
        description="The topic of the classification.",
    )

    def model_dump(self, *args, **kwargs):
        # Overriding this method allows us to set defaults
        # which reflect the necessary settings when sending things to the APIs
        kwargs.setdefault('exclude_none', True)
        kwargs.setdefault('by_alias', True)
        return super().model_dump(*args, **kwargs)

    def model_dump_json(self, *args, **kwargs):
        # Overriding this method allows us to set defaults
        # which reflect the necessary settings when sending things to the APIs
        # without the need to explicitly call them out
        kwargs.setdefault('exclude_none', True)
        kwargs.setdefault('by_alias', True)
        return super().model_dump_json(*args, **kwargs)
