Skip to main content
Conversations use generateChat, a separate method from generate.
Dart has no method overloading. generate takes a String only. Passing a list of messages to it does not compile.

How messages are split

  • System turns become options.systemPrompt.
  • The trailing user turn becomes the prompt.
  • Everything between travels as history.
A conversation with no user turn throws.

Streaming a conversation

Keeping a transcript

ChatMessage

Context length

Trim before the conversation outgrows the model’s window, keeping the system message: