use rig_core::conversation::Aside;
use crate::agent::{AgentHook, HookContext, HookStack};
use crate::handlers::Handlers;
#[derive(Debug)]
pub struct HookTestHarness {
hooks: HookStack,
context: HookContext,
}
impl HookTestHarness {
pub fn new() -> Self {
Self {
hooks: HookStack::new(),
context: HookContext::new(false, None, Handlers::default()),
}
}
pub fn with_hook(mut self, hook: impl AgentHook + 'static) -> Self {
self.hooks.push(hook);
self
}
pub fn with_streaming(mut self, is_streaming: bool) -> Self {
self.context.set_streaming(is_streaming);
self
}
pub fn with_agent_name(mut self, name: impl Into<String>) -> Self {
self.context.set_agent_name(name.into());
self
}
pub fn with_entries(self, entries: &[Aside]) -> Self {
self.context.seed_entries(entries);
self
}
pub fn set_turn(&self, turn: usize) {
self.context.set_turn(turn);
}
pub fn hooks(&self) -> &HookStack {
&self.hooks
}
pub fn context(&self) -> &HookContext {
&self.context
}
}
impl Default for HookTestHarness {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests;