Documentation
¶
Overview ¶
Package dialogram is the batteries-included entry point: pick a provider from settings, wrap it in an Agent, and you have a tool-using chat loop with streaming, human-in-the-loop pauses, inline generative UI and an optional honesty guard.
reg := tool.NewRegistry()
tool.RegisterHITL(reg)
tool.RegisterPresentData(reg)
reg.Register(myWeatherTool)
ag, err := dialogram.New(dialogram.SettingsFromEnv(), dialogram.Deps{
Registry: reg,
Config: &agent.Config{Profiles: map[string]agent.Profile{"assistant": {SystemPrompt: "..."}}, DefaultProfile: "assistant"},
})
The sub-packages are usable on their own: agent (block IR, profiles, guard), tool (registry + envelope), provider/anthropic and provider/openai (wire adapters), streambuf (resumable stream buffers), sse (the resumable HTTP handler) and eval (the evaluation harness).
Index ¶
Constants ¶
const ( ProviderAnthropic = "anthropic" ProviderOpenAI = "openai" )
Provider names accepted by Settings.Provider.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Deps ¶
type Deps struct {
Registry *tool.Registry
Config *agent.Config
Interceptors []agent.Interceptor
Skills *agent.SkillLibrary
// Executor runs tool calls; nil selects tool.NewLocalExecutor with the
// default limits.
Executor tool.Executor
// Checkpointer, when non-nil, receives the run's block IR at every
// step boundary so a crashed turn can be recovered (see
// agent.Checkpoint and docs/STREAMING.md).
Checkpointer agent.Checkpointer
// Guard, Metrics and TracerProvider are layered on by New (not
// NewProvider). A nil TracerProvider uses the global one, which records
// nothing until an OpenTelemetry SDK is installed.
Guard *agent.Guard
Metrics *agent.Metrics
TracerProvider trace.TracerProvider
}
Deps are the application-side pieces every provider receives.
type Settings ¶
type Settings struct {
// Provider is "anthropic" or "openai". Empty means anthropic when an
// Anthropic key is set, else openai.
Provider string
AnthropicAPIKey string
AnthropicModel string
AnthropicBaseURL string
OpenAIAPIKey string
OpenAIBaseURL string
OpenAIModel string
}
Settings select and configure the model backend.
func SettingsFromEnv ¶
func SettingsFromEnv() Settings
SettingsFromEnv reads LLM_PROVIDER, ANTHROPIC_API_KEY, ANTHROPIC_MODEL, ANTHROPIC_BASE_URL, OPENAI_API_KEY, OPENAI_BASE_URL and OPENAI_MODEL.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent is the provider-neutral core of dialogram: the block IR a conversation is persisted in, the Provider contract every model backend implements, the Agent wrapper that layers the honesty guard and metrics on top of a provider, and the supporting pieces the tool loop relies on (profiles, interceptors, skills, pause detection).
|
Package agent is the provider-neutral core of dialogram: the block IR a conversation is persisted in, the Provider contract every model backend implements, the Agent wrapper that layers the honesty guard and metrics on top of a provider, and the supporting pieces the tool loop relies on (profiles, interceptors, skills, pause detection). |
|
Package agui serves a dialogram run over the AG-UI protocol (https://docs.ag-ui.com), the event vocabulary that CopilotKit and the other AG-UI clients consume.
|
Package agui serves a dialogram run over the AG-UI protocol (https://docs.ag-ui.com), the event vocabulary that CopilotKit and the other AG-UI clients consume. |
|
Package eval is the evaluation harness for a dialogram agent, organised in three cheapest-first layers so the free tiers can gate every pull request and only the paid tier runs on a schedule:
|
Package eval is the evaluation harness for a dialogram agent, organised in three cheapest-first layers so the free tiers can gate every pull request and only the paid tier runs on a schedule: |
|
examples
|
|
|
agui
command
Command agui serves a weather assistant over the AG-UI protocol, for CopilotKit-style frontends: POST a RunAgentInput to /agui and read the event stream back.
|
Command agui serves a weather assistant over the AG-UI protocol, for CopilotKit-style frontends: POST a RunAgentInput to /agui and read the event stream back. |
|
chatserver
command
Command chatserver is a runnable reference deployment of dialogram: a chat assistant for trips and Singapore property with resumable streaming, inline charts and tables, human-in-the-loop choices, an approval-gated tool, an application-defined pause, an Agent Skills package and an in-memory conversation store.
|
Command chatserver is a runnable reference deployment of dialogram: a chat assistant for trips and Singapore property with resumable streaming, inline charts and tables, human-in-the-loop choices, an approval-gated tool, an application-defined pause, an Agent Skills package and an in-memory conversation store. |
|
mcpagent
command
Command mcpagent is a terminal agent whose tools all come from one MCP server.
|
Command mcpagent is a terminal agent whose tools all come from one MCP server. |
|
mcptools
command
Command mcptools connects to an MCP server, registers its tools into a dialogram tool.Registry and prints what the model would see: the registered names and the Anthropic tool spec with each server's input schema passed through.
|
Command mcptools connects to an MCP server, registers its tools into a dialogram tool.Registry and prints what the model would see: the registered names and the Anthropic tool spec with each server's input schema passed through. |
|
internal
|
|
|
loop
Package loop holds the provider-neutral machinery both wire translators share: tool dispatch through the interceptor chain, pause handling for mixed turns, system-prompt composition, retry/backoff and token estimation.
|
Package loop holds the provider-neutral machinery both wire translators share: tool dispatch through the interceptor chain, pause handling for mixed turns, system-prompt composition, retry/backoff and token estimation. |
|
telemetry
Package telemetry is the OpenTelemetry vocabulary dialogram's spans share: the instrumentation scope, operation and event names, attribute keys, and the helpers the loop and the provider adapters use to start child spans.
|
Package telemetry is the OpenTelemetry vocabulary dialogram's spans share: the instrumentation scope, operation and event names, attribute keys, and the helpers the loop and the provider adapters use to start child spans. |
|
provider
|
|
|
anthropic
Package anthropic is the Anthropic Messages API adapter for dialogram.
|
Package anthropic is the Anthropic Messages API adapter for dialogram. |
|
internal/replay
Package replay serves recorded upstream responses to the provider adapters under test and records what each adapter sent.
|
Package replay serves recorded upstream responses to the provider adapters under test and records what each adapter sent. |
|
openai
Package openai is the OpenAI Chat Completions adapter for dialogram.
|
Package openai is the OpenAI Chat Completions adapter for dialogram. |
|
Package sse serves a resumable chat stream over Server-Sent Events.
|
Package sse serves a resumable chat stream over Server-Sent Events. |
|
Package streambuf persists in-flight streaming events keyed by a client-supplied message id so that a client can disconnect (tab switch, network drop, mobile backgrounding) and reconnect to resume from where it left off — the pattern the major chat products use.
|
Package streambuf persists in-flight streaming events keyed by a client-supplied message id so that a client can disconnect (tab switch, network drop, mobile backgrounding) and reconnect to resume from where it left off — the pattern the major chat products use. |
|
Package tool is the tool layer of dialogram: the Tool contract, the Registry the agent loop dispatches through, the three-channel result Envelope, the ArtifactStore that backs opaque data handles, and a handful of built-in tools (human-in-the-loop pauses, inline UI rendering, a clock).
|
Package tool is the tool layer of dialogram: the Tool contract, the Registry the agent loop dispatches through, the three-channel result Envelope, the ArtifactStore that backs opaque data handles, and a handful of built-in tools (human-in-the-loop pauses, inline UI rendering, a clock). |
|
mcp
Package mcp connects a dialogram tool.Registry to Model Context Protocol servers.
|
Package mcp connects a dialogram tool.Registry to Model Context Protocol servers. |







