ailets

Content type definition

To have interoperability between different models, we define a common content type.

Each model is expected to get a sequence of ChatMessages as input and produce a sequence of ChatMessages as output.

ChatMessage

A ChatMessage represents a message in a chat conversation. It is defined as a TypedDict with two required fields:

ContentItem

ContentItemText: Text content with fields:

ContentItemRefusal: Refusal message with fields:

ContentItemImage: Image content with fields:

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:

There 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.