Skip to main content

Module brain

Module brain 

Source
Expand description

Brain module — LLM provider abstraction and interaction.

Defines the LlmProvider trait for model-agnostic LLM interactions, and provides an OpenAI-compatible implementation with streaming support.

Structs§

Brain
The Brain wraps an LLM provider and adds higher-level logic: prompt construction, cost tracking, and model selection.
MockLlmProvider
A mock LLM provider for testing and development.
TokenBudgetManager
Tracks token usage against configurable budgets and predicts costs before execution. Can warn or halt when budgets are exceeded.
TokenCounter
Token counter using tiktoken-rs for accurate BPE tokenization.

Enums§

BudgetCheckResult
The result of a pre-call budget check.

Constants§

DEFAULT_SYSTEM_PROMPT
The system prompt used by default for the Rustant agent.

Traits§

LlmProvider
Trait for LLM providers, supporting both full and streaming completions.

Functions§

sanitize_tool_sequence
Sanitize tool_call → tool_result ordering in a message sequence.