use crate::{
CallControl, Context, ContextFrame, GenerationOptions, InvocationId, ModelRef, ToolSurface,
};
use async_trait::async_trait;
#[non_exhaustive]
pub struct RoundInfo<'a> {
pub invocation_id: &'a InvocationId,
pub model: &'a ModelRef,
pub tool_surface: &'a ToolSurface,
pub generation: &'a GenerationOptions,
}
impl<'a> RoundInfo<'a> {
pub fn new(
invocation_id: &'a InvocationId,
model: &'a ModelRef,
tool_surface: &'a ToolSurface,
generation: &'a GenerationOptions,
) -> Self {
Self {
invocation_id,
model,
tool_surface,
generation,
}
}
}
#[derive(Debug, thiserror::Error)]
#[error("{message}")]
#[non_exhaustive]
pub struct PrepareError {
pub message: String,
}
impl PrepareError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
#[async_trait]
pub trait ContextPreparer: Send + Sync {
async fn prepare(
&self,
context: &mut Context,
round: &RoundInfo<'_>,
control: &CallControl,
) -> Result<ContextFrame, PrepareError>;
}