# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .create_feedback_request_target_type import CreateFeedbackRequestTargetType


class CreateFeedbackRequest(UncheckedBaseModel):
    """
    Request to create new feedback.

    User identification follows Braintrust's pattern - pass user_id in metadata:
        {
            "target_type": "workflow_run",
            "target_id": "run_123",
            "scorer_id": "thumbs",
            "score": 1,
            "metadata": {
                "user_id": "customer_456",
                "workflow_id": "wf_abc",
                "session_id": "sess_789"
            }
        }

    Required metadata fields by target_type:
        - workflow_run: workflow_id, session_id
    """

    target_type: CreateFeedbackRequestTargetType
    target_id: str
    scorer_id: str
    score: typing.Optional[float] = None
    selected_option: typing.Optional[str] = None
    comment: typing.Optional[str] = None
    correction: typing.Optional[typing.Optional[typing.Any]] = None
    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
