Omni.Context (Omni v1.2.1)

Copy Markdown View Source

The context for a conversation with an LLM.

Wraps a system prompt, a list of messages, and a list of tools — passed as the second argument to Omni.generate_text/3 and Omni.stream_text/3.

Summary

Types

t()

System prompt, messages, and tools for a generation request.

Functions

Creates a new context from a string, list of messages, keyword list, or map.

Appends messages to the context.

Types

t()

@type t() :: %Omni.Context{
  messages: [Omni.Message.t()],
  system: String.t() | nil,
  tools: [Omni.Tool.t()]
}

System prompt, messages, and tools for a generation request.

Functions

new(attrs \\ [])

@spec new(Enumerable.t() | String.t() | [Omni.Message.t()] | t()) :: t()

Creates a new context from a string, list of messages, keyword list, or map.

A string is treated as a single user message. A list is treated as messages.

push(context, message)

@spec push(t(), Omni.Message.t() | [Omni.Message.t()] | Omni.Response.t()) :: t()

Appends messages to the context.

Accepts a single %Message{}, a list of messages, or a %Response{} (extracts its messages field — the right choice after a tool loop).