Expand description
Context construction and multi-adapter composition.
The ContextAdapter trait defines pluggable context sources such as
system prompts, conversation history, memory, or RAG retrieval. The
ContextFactory composes multiple adapters in order to produce
a complete Vec<Message> for chat requests.
§Example
use behest::context::{ContextAdapter, ContextFactory, ContextInput, StaticAdapter};
use behest::provider::Message;
#[tokio::main]
async fn main() {
let mut factory = ContextFactory::new();
factory.register(StaticAdapter::system("You are a helpful assistant."));
factory.register(StaticAdapter::user("Hello, how are you?"));
let input = ContextInput::default();
let output = factory.build(&input).await.unwrap();
assert_eq!(output.messages().len(), 2);
}Structs§
- Context
Factory - Multi-adapter context factory.
- Context
Input - Input provided to context adapters.
- Context
Output - Output produced by context construction.
- Function
Adapter - Function-based context adapter.
- Static
Adapter - Static context adapter that returns fixed messages.
Traits§
- Context
Adapter - Pluggable context source that produces message fragments.
Type Aliases§
- Context
Result - Result type for context operations.