from typing import ClassVar

from .spec import OtelGenAISpecification
from .types import FINISH_REASONS, MESSAGE_ROLES, OPTIONAL, REQUIRED, AttributeSpec


class OtelGenAIOutputMessageSpecification(OtelGenAISpecification):
    """OpenTelemetry GenAI output message specification.

    Validates output messages with required role, parts, and finish_reason attributes.
    """
    SPEC_VERSION: ClassVar[str] = "1.38.0"

    SUPPORTED_ATTRIBUTES: ClassVar[dict[str, AttributeSpec]] = {
        "finish_reason": AttributeSpec(
            name="finish_reason",
            requirement=REQUIRED,
            type="string",
            valid_values=FINISH_REASONS,
        ),
        "name": AttributeSpec(
            name="name",
            requirement=OPTIONAL,
            type="string",
        ),
        "parts": AttributeSpec(
            name="parts",
            requirement=REQUIRED,
            type="any",
        ),
        "role": AttributeSpec(
            name="role",
            requirement=REQUIRED,
            type="string",
            valid_values=MESSAGE_ROLES,
        ),
    }
