llm-pipeline
Reusable node payloads for LLM workflows: prompt templating, multi-backend calls (Ollama/OpenAI), defensive parsing, streaming, sequential chaining, tool loops, retry policies, and provider routing.
What it gives you
- Prompt templating:
{{variable}}interpolation with context injection - Multi-backend calls: Ollama and OpenAI-compatible endpoints via feature flags
- Defensive parsing: JSON/text extraction from model responses via
llm-output-parser - Streaming: token-by-token streaming through
PayloadContextcallback - Sequential chaining: compose multiple
LlmCallstages into pipelines - Tool loops:
tool_loopmodule for multi-turn tool-calling workflows - Retry policies: configurable retry with backoff via
retry_policy - Output strategies:
Text,JsonObject,JsonArray,ThinkingMode - Payload trait: implements
agent_graph::Payloadfor use as graph nodes - Trace integration:
TraceCtxfromstack-idsfor request correlation
Quick start
use ;
let ctx = builder.build?;
let call = new
.with_model
.with_output_strategy;
let output = call.invoke.await?;
println!;
Multi-provider routing (OpenAI feature)
use ;
let ctx = builder
.with_api_key
.build?;
let call = new
.with_model
.with_output_strategy;
let output = call.invoke.await?;
Streaming pipeline
use ;
let ctx = builder.build?;
let call = new
.with_model
.with_streaming;
// Tokens stream through PayloadContext::on_token callback
// when used as an agent-graph node
let output = call.invoke.await?;
Payload chain
Compose multiple LLM calls into a sequential pipeline:
use ;
let ctx = builder.build?;
let pipeline = new
.stage
.stage;
let output = pipeline.run.await?;
Examples
Ecosystem
- stack-ids:
TraceCtxfor request correlation,AttemptId/TrialIdfor retry lineage - agent-graph:
LlmCallimplementsPayloadtrait for use as graph nodes - llm-output-parser: Defensive JSON/text extraction from model responses
- llm-tool-runtime: Provider-agnostic tool contracts, registry, dispatch
- agent-graph-mcp: MCP server exposing graph-orchestrated LLM workflows
stack-ids integration
Fully integrated. TraceCtx is re-exported from the crate root. Per-call trace context flows through the execution pipeline.
Verification
License
MIT