To have interoperability between different models, we define a common content type.
Each model is expected to get a sequence of ChatMessage
s as input and produce a sequence of ChatMessage
s as output.
ChatMessage
A ChatMessage
represents a message in a chat conversation. It is defined as a TypedDict with two required fields:
role
: A literal string that must be one of: “system”, “user”, “assistant”, or “tool”
system
: The system promptuser
: A user messageassistant
: An assistant messagetool
: Tool outputcontent
: A sequence of content itemsContentItem
ContentItemText
: Text content with fields:
type: "text"
text: str
- The actual text contentContentItemRefusal
: Refusal message with fields:
type: "refusal"
refusal: str
- The refusal messageContentItemImage
: Image content with fields:
type: "image"
content_type: str
- MIME type of the image, for example image/png
url: str
or stream: str
(but not both)For url
, some models produce and accept data URLs. Ailets should prefer stream
over url
, where stream
is a named file stream inside ailets’ runtime.
The recommended stream name is media/image.*
.
If the stream name is out/*
, ailets will save the file to the output directory. The name of the file is the md5 of the stream content.
ContentItemFunction
: Function call with fields:
type: "function"
id: str
- Function call identifierfunction: dict
containing:
name: str
- Function namearguments: str
- Function argumentsThere is no content item representing the result of a function call. Instead, the ChatMessage
with the role tool
is used for that purpose. The tool result is then represented as Content
.