Generates titles for conversations.
Two strategies are exposed through a single entry point, generate/3:
- Heuristic (
:heuristic) — picks the first message with extractable text and truncates it. No LLM call. - Model (
Omni.Model.ref()or%Omni.Model{}) — asks the given model to summarise the first few turns into a concise title.
Both branches return {:error, :no_text} when no message contains any
%Omni.Content.Text{} content. Attachments, thinking blocks, tool
uses, and tool results are filtered out — only text contributes.
This module is pure: it makes at most one HTTP call (in the model branch) and holds no state.
Summary
Functions
Generates a title for the given conversation.
Functions
@spec generate( :heuristic | Omni.Model.t() | Omni.Model.ref(), [Omni.Message.t()], keyword() ) :: {:ok, String.t()} | {:error, term()}
Generates a title for the given conversation.
When strategy is :heuristic, falls back to truncating the first
text-bearing message. When strategy is an Omni.Model.ref() (or
%Omni.Model{}), asks the model to summarise the conversation.
Returns {:error, :no_text} when no extractable text exists — for the
model branch, this is checked against the first four messages.
Options
Options are passed through to Omni.generate_text/3 when using the
model strategy. Common options include :api_key and :plug (for
testing).