Sycophant.Context
(sycophant v0.4.2)
Copy Markdown
Public conversation handle for multi-turn LLM interactions.
Context is a builder for conversation state. It holds message history, tools, streaming callbacks, and provider params. Model and response schema are per-call concerns and live outside the context.
Building a conversation
ctx = Context.new()
|> Context.add(Message.system("You are helpful."))
|> Context.add(Message.user("Hello!"))Passing options
opts = Context.to_opts(ctx)
Summary
Functions
Appends one or more messages to the context.
Deserializes a context from a plain map.
Creates an empty context.
Creates a context from a message list or keyword opts.
Creates a context from messages and keyword opts.
Converts context fields into flat keyword opts for pipeline consumption.
Types
@type t() :: %Sycophant.Context{ messages: [Sycophant.Message.t()], params: map(), stream: (term() -> term()) | {term(), (term(), term() -> term())} | nil, tools: [Sycophant.Tool.t()] }
Functions
@spec add(t(), Sycophant.Message.t() | [Sycophant.Message.t()]) :: t()
Appends one or more messages to the context.
Deserializes a context from a plain map.
@spec new() :: t()
Creates an empty context.
@spec new([Sycophant.Message.t()] | keyword()) :: t()
Creates a context from a message list or keyword opts.
@spec new( [Sycophant.Message.t()], keyword() ) :: t()
Creates a context from messages and keyword opts.
Converts context fields into flat keyword opts for pipeline consumption.