# generated by datamodel-codegen:
#   filename:  text_generation_v1.json
#   timestamp: 2025-12-12T07:02:32+00:00

from __future__ import annotations

from enum import Enum

from pydantic import BaseModel, ConfigDict, Field


class FinishReason(Enum):
    """
    Reason why generation terminated
    """

    stop = 'stop'
    length = 'length'
    eos_token = 'eos_token'
    stop_sequence = 'stop_sequence'
    error = 'error'


class Metadata(BaseModel):
    """
    Optional metadata about the generation process
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    temperature: float | None = Field(None, ge=0.0)
    """
    Sampling temperature used for generation
    """
    top_p: float | None = Field(None, ge=0.0, le=1.0)
    """
    Nucleus sampling parameter used for generation
    """
    max_tokens: int | None = Field(None, ge=1)
    """
    Maximum tokens allowed for generation
    """
    seed: int | None = None
    """
    Random seed used for generation (if deterministic)
    """
    generation_time_ms: float | None = Field(None, ge=0.0)
    """
    Time taken to generate the response in milliseconds
    """
    streaming_chunks: int | None = Field(None, ge=0)
    """
    Number of chunks in streaming generation (if applicable)
    """


class TextGenerationV1(BaseModel):
    """
    Universal schema for text generation responses across Lumen VLM services. Returns generated text with metadata about the generation process.
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    text: str = Field(..., min_length=0)
    """
    Generated text content
    """
    finish_reason: FinishReason
    """
    Reason why generation terminated
    """
    generated_tokens: int = Field(..., ge=0)
    """
    Number of tokens generated in the response
    """
    input_tokens: int | None = Field(None, ge=0)
    """
    Number of tokens in the input prompt
    """
    model_id: str = Field(..., min_length=1)
    """
    Identifier of the model that generated the text
    """
    metadata: Metadata | None = None
    """
    Optional metadata about the generation process
    """
