# 消息 消息代表了模型对话的单轮信息。消息的定义为: ```python class FunctionCall(TypedDict, total=False): name: str arguments: Union[str, Dict[str, Any]] class ToolCall(TypedDict, total=False): id: str type: Literal['function'] function: FunctionCall class Message(TypedDict, total=False): role: Literal['system', 'user', 'assistant', 'tool'] type: str content: Union[str, List[Dict[str, str]]] tool_calls: List[ToolCall] tool_call_id: str reasoning_content: str images: Optional[List[Union[str, Any]]] videos: Optional[List[Union[str, Any]]] audios: Optional[List[Union[str, Any]]] ``` 本质上,`Message`是一个Dict。里面包含了若干字段,和开发者强相关的有: - role: 消息类型,包含了'system', 'user', 'assistant', 'tool'四类。 - system: 系统指令消息,仅在第0个消息中出现 - user: 用户输入消息 - assistant: 模型回复的消息 - tool: 工具调用结果,类似user消息输入给模型 - content: 消息正文,如果包含多模态信息,则需要有占位符: - : 图片占位符 -