[docs]classFunction(BaseModel):""" The function called by the model. Args: name: The name of the function. arguments: The arguments of the function. """name:strarguments:Dict[str,Any]
[docs]classChatMessage(BaseModel):""" The generated chat message. Args: role: The role of the author of this message. content: The content of the message. """role:Optional[str]=Nonecontent:Optional[str]=None
[docs]classChatToolCall(BaseModel):""" A chat tool call. Args: id: A unique identifier of the tool call. function: The function called. type: The function type. Always "function". """id:Optional[str]=Nonefunction:Functiontype:str="function"
[docs]classChatUsage(BaseModel):""" Usage statistics for a chat response. Args: input_tokens: The number of input tokens used. output_tokens: The number of output tokens generated. total_tokens: The total number of tokens used. """input_tokens:Optional[int]=Noneoutput_tokens:Optional[int]=Nonetotal_tokens:Optional[int]=None
[docs]classChatResponse(BaseModel):""" Represents a chat response from the model, based on the provided input. Args: id: A unique identifier of the response. message: The generated message. tool_calls: A list of tool calls. usage: Usage statistics. finish_reason: The reason the generation finished. This will be ``completed`` if the generation was successful, ``max_tokens`` if the maximum token limit was reached,``content_filter`` if the content filter blocked the response,``tool_calls`` if the model called a tool, or ``unknown`` if the reason is unknown. """id:Optional[str]=Nonemessage:Optional[ChatMessage]=Nonetool_calls:Optional[List[ChatToolCall]]=Noneusage:Optional[ChatUsage]=Nonefinish_reason:Optional[str]=None
[docs]classEmbedding(BaseModel):""" An embedding vector representing the input text. Args: index: The index of the embedding in the list of embeddings. data: The embedding vector, which is a list of floats. """index:intdata:List[float]
[docs]classEmbeddingUsage(BaseModel):""" Usage statistics for an embedding response. Args: input_tokens: The number of input tokens used. total_tokens: The total number of tokens used. """input_tokens:Optional[int]=Nonetotal_tokens:Optional[int]=None
[docs]classEmbeddingResponse(BaseModel):""" Represents an embedding response from the model, based on the provided input. Args: id: A unique identifier of the response. object: The object type. model: The model used to generate the response. usage: Usage statistics. embeddings: A list of embeddings. """id:Optional[str]=Noneobject:Optional[str]=Nonemodel:Optional[str]=Noneusage:Optional[EmbeddingUsage]=Noneembeddings:List[Embedding]
[docs]classTranscriptionResponse(BaseModel):""" A transcription of an input audio. Args: text: The transcribed text. """text:str
[docs]classImageGenerationResponse(BaseModel):""" Represents an image generation response from the model, based on the provided input. Args: images: A list of generated images. """images:List[Any]@field_validator("images",mode="before")defvalidate_images(cls,value):ifisinstance(value,list):forimginvalue:ifnotisinstance(img,Image):raiseValidationError("Each item must be a valid PIL.Image instance.")returnvalueraiseValidationError("The value must be a list of PIL.Image instances.")