use rap_protocol::ThreadId;
use std::rc::Rc;
use async_trait::async_trait;
use crate::tools::Tool;
use crate::traits::InputSender;
use rap_client::http::HttpClient;
use rap_client::notifier::RapNotifier;
type BoxError = Box<dyn std::error::Error + Send + Sync>;
pub struct ThreadConfig<M: InputSender, H: HttpClient> {
pub tools: Vec<Rc<dyn Tool<M>>>,
pub extra_system_prompt: Option<String>,
pub rap_notifier: Option<RapNotifier<H>>,
}
#[async_trait(?Send)]
pub trait ThreadConfigSource<M: InputSender, H: HttpClient> {
async fn resolve(&self, thread_id: &ThreadId<str>) -> Result<ThreadConfig<M, H>, BoxError>;
}
pub struct StaticThreadConfig<M: InputSender, H: HttpClient> {
pub tools: Vec<Rc<dyn Tool<M>>>,
pub extra_system_prompt: Option<String>,
pub rap_notifier: Option<RapNotifier<H>>,
}
#[async_trait(?Send)]
impl<M: InputSender + 'static, H: HttpClient + 'static> ThreadConfigSource<M, H>
for StaticThreadConfig<M, H>
{
async fn resolve(&self, _thread_id: &ThreadId<str>) -> Result<ThreadConfig<M, H>, BoxError> {
Ok(ThreadConfig {
tools: self.tools.clone(),
extra_system_prompt: self.extra_system_prompt.clone(),
rap_notifier: self.rap_notifier.clone(),
})
}
}