AgentSea. Provider behaviour
(agentsea_core v0.1.0)
Copy Markdown
A chat-completion backend (Anthropic, OpenAI, a local model, …).
Every LLM integration implements this behaviour. Streaming is optional and,
where supported, returns a lazy Stream of normalized chunks built from an
SSE body — there is no async-generator plumbing.
Summary
Types
A single conversation message. role is required; extra keys (e.g. tool_calls, tool_call_id) are allowed.
Provider options (model, api_key, system_prompt, tools, …).
A streamed event from stream/2.
Callbacks
Run a single (non-streaming) completion.
Static capabilities for a model id; nil for unknown models.
Run a streaming completion, returning a lazy stream of stream_event/0.
Types
@type message() :: %{ :role => :system | :user | :assistant | :tool, :content => term(), optional(atom()) => term() }
A single conversation message. role is required; extra keys (e.g. tool_calls, tool_call_id) are allowed.
@type opts() :: keyword()
Provider options (model, api_key, system_prompt, tools, …).
@type stream_event() :: {:content, String.t()} | {:thinking, String.t()} | {:tool_call, map()} | :done
A streamed event from stream/2.
Callbacks
@callback complete([message()], opts()) :: {:ok, AgentSea.Response.t()} | {:error, term()}
Run a single (non-streaming) completion.
@callback model_info(model :: String.t()) :: AgentSea.ModelInfo.t() | nil
Static capabilities for a model id; nil for unknown models.
@callback stream([message()], opts()) :: Enumerable.t()
Run a streaming completion, returning a lazy stream of stream_event/0.