# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Dict, List, Union, Optional

from .._models import BaseModel

__all__ = ["ChatCreateCompletionResponse", "Message", "MessageContentUnionMember1", "AssistantOutput"]


class MessageContentUnionMember1(BaseModel):
    """A single content part within a multimodal message"""

    type: str
    """Content type: 'text', 'image', 'video', 'audio', or 'image_url'"""

    audio_url: Optional[Dict[str, str]] = None
    """Audio URL object with 'url' key"""

    content: Optional[str] = None
    """Base64 encoded content (for image/video/audio)"""

    format: Optional[str] = None
    """Asset format, e.g. png, jpeg, mp3, wav, mp4"""

    image_url: Optional[Dict[str, str]] = None
    """Image URL object with 'url' key (can be data:image/... base64)"""

    text: Optional[str] = None
    """Text content (when type='text')"""

    url: Optional[str] = None
    """Signed GCS URL to download the asset (expires after 24 h)"""

    video_url: Optional[Dict[str, str]] = None
    """Video URL object with 'url' key"""


class Message(BaseModel):
    """A single message in the conversation"""

    content: Union[str, List[MessageContentUnionMember1], List[Dict[str, object]]]
    """
    Message content - can be: - A simple text string - An array of content parts for
    multimodal input: [ {"type": "text", "text": "What's in this image?"}, {"type":
    "image", "content": "base64_encoded_image..."}, {"type": "image_url",
    "image_url": {"url": "data:image/jpeg;base64,..."}}, {"type": "video",
    "content": "base64_encoded_video..."}, {"type": "audio", "content":
    "base64_encoded_audio..."} ]
    """

    role: str
    """Message role: 'system', 'user', or 'assistant'"""


class AssistantOutput(BaseModel):
    """
    Convenience extraction of just the assistant's reply — useful for
    stateless integrations like Instagram that only need the response.
    """

    audio_base64: Optional[str] = None
    """Base64-encoded audio (if any)"""

    audio_url: Optional[str] = None
    """Signed URL for the audio (if any)"""

    image_base64: Optional[str] = None
    """Base64-encoded image (if any)"""

    image_url: Optional[str] = None
    """Signed URL for the image (if any)"""

    text: Optional[str] = None
    """Plain-text portion of the reply"""


class ChatCreateCompletionResponse(BaseModel):
    """
    Response model for chat completions - returns the full conversation including the assistant's reply
    """

    messages: List[Message]
    """
    Full conversation: the original user messages plus the assistant's response
    appended
    """

    session_id: str
    """Session ID for conversation context"""

    agent_trace: Optional[List[Dict[str, object]]] = None
    """
    Agent execution trace — present only when the request was handled by the agent
    service
    """

    assistant_output: Optional[AssistantOutput] = None
    """
    Convenience extraction of just the assistant's reply — useful for stateless
    integrations like Instagram that only need the response.
    """
