Expand description
Foundation crate for the ailoop workspace: shared vocabulary used
by the ailoop façade and by every adapter / middleware crate.
Most application code does not depend on ailoop-core directly —
it depends on ailoop, which re-exports the types you need to
build a Conversation and write a ChatMiddleware. Reach for
ailoop-core when:
- implementing a new
CompletionModel/CompletionClientadapter for a provider HTTP API; - writing a generic middleware that should be reusable across façades, examples, or test harnesses;
- building reliability or observability infrastructure on top of the shared event vocabulary.
§Layout
Message,UserBlock,AssistantBlock,ToolResultContent,SystemPrompt— the wire model exchanged between the engine and the provider.ChatRequest,ToolDefinition,ToolChoice,ToolTag— the per-turn request shape adapters lower to the provider.StreamChunk,FinishReason,Usage— the event stream the engine emits for every run.ChatMiddleware,HookAction,ToolDecision— the extension point for transforms, gating, and observation.CompletionClient,CompletionModel— the contract every provider adapter implements.RetryingModel,Retryable,RetryConfig— backoff decorator that wraps anyCompletionModel.
Re-exports§
pub use config::RunConfig;pub use ids::RunId;pub use ids::StepId;pub use message::AssistantBlock;pub use message::CacheControl;pub use message::Message;pub use message::Source;pub use message::SystemBlock;pub use message::SystemPrompt;pub use message::ToolResultBlock;pub use message::ToolResultContent;pub use message::UserBlock;pub use middleware::ChatMiddleware;pub use middleware::HookAction;pub use middleware::ToolDecision;pub use request::ChatRequest;pub use request::ToolChoice;pub use request::ToolDefinition;pub use request::ToolTag;pub use retry::RetryClassification;pub use retry::RetryConfig;pub use retry::Retryable;pub use retry::RetryingModel;pub use stream::FinishReason;pub use stream::StreamChunk;pub use stream::Usage;
Modules§
- config
- Per-run configuration: see
RunConfig. - ids
- Run and step identifiers used by the engine to correlate
crate::StreamChunks andcrate::ChatMiddlewarehooks. - message
- Conversation message model:
Message, its block enums, and theSystemPrompt/CacheControlsupport types. - middleware
ChatMiddlewareextension point and its decision enums (HookAction,ToolDecision).- request
- Per-turn request shape:
ChatRequestplusToolChoice,ToolDefinition, andToolTag. - retry
- Reliability decorator:
RetryingModelwraps anyCompletionModeland retries setup-time failures with exponential backoff that honoursRetry-Afterhints surfaced by the adapter. - stream
- Engine event vocabulary:
StreamChunk,FinishReason, andUsage.
Structs§
- Cancellation
Token - A token which can be used to signal a cancellation request to one or more tasks.
- Char
Tokenizer - Fallback
Tokenizerthat approximates tokens astext.len() / 4.
Traits§
- Completion
Client - Factory for
CompletionModelhandles bound to a provider account / endpoint. - Completion
Model - Provider-agnostic streaming completion contract.
- Tokenizer
- Counts tokens in text and full messages.