use std::sync::Arc;
use std::time::Duration;
use super::base::{BaseLLM, BatchReq, ChatCompletion, LlmOpts};
use crate::core::exceptions::OperonError;
#[derive(Debug, Clone)]
pub struct BatchSettings {
pub batch_size: usize,
pub flush_interval: Duration,
pub poll_interval: Duration,
pub timeout: Duration,
}
impl Default for BatchSettings {
fn default() -> Self {
Self {
batch_size: 100,
flush_interval: Duration::from_secs(5),
poll_interval: Duration::from_secs(30),
timeout: Duration::from_secs(3600),
}
}
}
pub struct BatchCoordinator {
pub resource: String,
pub llm: Arc<dyn BaseLLM>,
pub settings: BatchSettings,
}
impl BatchCoordinator {
pub fn new(
resource: impl Into<String>,
llm: Arc<dyn BaseLLM>,
settings: BatchSettings,
) -> Self {
Self {
resource: resource.into(),
llm,
settings,
}
}
pub async fn submit(
&self,
_reqs: Vec<BatchReq>,
_opts: &LlmOpts,
) -> Result<Vec<ChatCompletion>, OperonError> {
Err(OperonError::Provider(format!(
"BatchCoordinator::submit not yet implemented (Phase 6) โ resource={}",
self.resource
)))
}
}
impl std::fmt::Debug for BatchCoordinator {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("BatchCoordinator")
.field("resource", &self.resource)
.field("settings", &self.settings)
.finish()
}
}