1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2
  3from typing import List, Union, Optional
  4from typing_extensions import Literal, TypeAlias
  5
  6from ...._models import BaseModel
  7from .message_content import MessageContent
  8from ...shared.metadata import Metadata
  9from ..code_interpreter_tool import CodeInterpreterTool
 10
 11__all__ = [
 12    "Message",
 13    "Attachment",
 14    "AttachmentTool",
 15    "AttachmentToolAssistantToolsFileSearchTypeOnly",
 16    "IncompleteDetails",
 17]
 18
 19
 20class AttachmentToolAssistantToolsFileSearchTypeOnly(BaseModel):
 21    type: Literal["file_search"]
 22    """The type of tool being defined: `file_search`"""
 23
 24
 25AttachmentTool: TypeAlias = Union[CodeInterpreterTool, AttachmentToolAssistantToolsFileSearchTypeOnly]
 26
 27
 28class Attachment(BaseModel):
 29    file_id: Optional[str] = None
 30    """The ID of the file to attach to the message."""
 31
 32    tools: Optional[List[AttachmentTool]] = None
 33    """The tools to add this file to."""
 34
 35
 36class IncompleteDetails(BaseModel):
 37    reason: Literal["content_filter", "max_tokens", "run_cancelled", "run_expired", "run_failed"]
 38    """The reason the message is incomplete."""
 39
 40
 41class Message(BaseModel):
 42    id: str
 43    """The identifier, which can be referenced in API endpoints."""
 44
 45    assistant_id: Optional[str] = None
 46    """
 47    If applicable, the ID of the
 48    [assistant](https://platform.openai.com/docs/api-reference/assistants) that
 49    authored this message.
 50    """
 51
 52    attachments: Optional[List[Attachment]] = None
 53    """A list of files attached to the message, and the tools they were added to."""
 54
 55    completed_at: Optional[int] = None
 56    """The Unix timestamp (in seconds) for when the message was completed."""
 57
 58    content: List[MessageContent]
 59    """The content of the message in array of text and/or images."""
 60
 61    created_at: int
 62    """The Unix timestamp (in seconds) for when the message was created."""
 63
 64    incomplete_at: Optional[int] = None
 65    """The Unix timestamp (in seconds) for when the message was marked as incomplete."""
 66
 67    incomplete_details: Optional[IncompleteDetails] = None
 68    """On an incomplete message, details about why the message is incomplete."""
 69
 70    metadata: Optional[Metadata] = None
 71    """Set of 16 key-value pairs that can be attached to an object.
 72
 73    This can be useful for storing additional information about the object in a
 74    structured format, and querying for objects via API or the dashboard.
 75
 76    Keys are strings with a maximum length of 64 characters. Values are strings with
 77    a maximum length of 512 characters.
 78    """
 79
 80    object: Literal["thread.message"]
 81    """The object type, which is always `thread.message`."""
 82
 83    role: Literal["user", "assistant"]
 84    """The entity that produced the message. One of `user` or `assistant`."""
 85
 86    run_id: Optional[str] = None
 87    """
 88    The ID of the [run](https://platform.openai.com/docs/api-reference/runs)
 89    associated with the creation of this message. Value is `null` when messages are
 90    created manually using the create message or create thread endpoints.
 91    """
 92
 93    status: Literal["in_progress", "incomplete", "completed"]
 94    """
 95    The status of the message, which can be either `in_progress`, `incomplete`, or
 96    `completed`.
 97    """
 98
 99    thread_id: str
100    """
101    The [thread](https://platform.openai.com/docs/api-reference/threads) ID that
102    this message belongs to.
103    """