from typing import Literal, NotRequired, TypedDict

ERROR = "error"
INFO = "info"
OPTIONAL = "optional"

RECOMMENDED = "recommended"
REQUIRED = "required"
WARNING = "warning"


MODALITY_VALUES: list[str] = [
    "image",
    "video",
    "audio",
]

MESSAGE_ROLES: list[str] = [
    "system",
    "user",
    "assistant",
    "tool",
]

FINISH_REASON_VALUES = ("stop", "length", "content_filter", "tool_call", "error")
FinishReason = Literal["stop", "length", "content_filter", "tool_call", "error"]

FINISH_REASONS: list[str] = list(FINISH_REASON_VALUES)

OTLP_STATUS_CODE_MAP: dict[int, str] = {
    0: "UNSET",
    1: "OK",
    2: "ERROR",
}

OTLP_SPAN_KIND_MAP: dict[int, str] = {
    0: "SpanKind.UNSPECIFIED",
    1: "SpanKind.INTERNAL",
    2: "SpanKind.SERVER",
    3: "SpanKind.CLIENT",
    4: "SpanKind.PRODUCER",
    5: "SpanKind.CONSUMER",
}


AttributeRequirement = Literal[OPTIONAL, RECOMMENDED, REQUIRED]
AttributeSeverity = Literal[ERROR, INFO, WARNING]
AttributeType = Literal["string", "int", "double", "boolean", "string[]", "any"]


class AttributeMetadata(TypedDict):
    environment: str | None
    model_provider: str | None
    model: str | None
    project_id: str | None
    session_id: str | None
    start_time: str | None
    end_time: str | None
    span_id: str | None
    span_parent_id: str | None
    trace_id: str | None
    user_id: str | None


class AttributeSpec(TypedDict):
    name: str
    requirement: AttributeRequirement
    type: NotRequired[AttributeType]
    deprecated: NotRequired[bool]
    deprecated_message: NotRequired[str]
    valid_values: NotRequired[list[str]]


class AttributeValidationDetail(TypedDict):
    name: str
    requirement: AttributeRequirement
    severity: AttributeSeverity
    type: NotRequired[AttributeType]
    deprecated: NotRequired[bool]
    deprecated_message: NotRequired[str]
    valid_values: NotRequired[list[str]]


AttributeValidationDetails = dict[str, AttributeValidationDetail]
