use anyhow::Result;
use std::sync::Arc;
use crate::provider::Provider;
use crate::rlm::context_trace::{ContextTrace, ContextTraceSummary};
use crate::rlm::oracle::TraceStep;
use crate::rlm::{RlmAnalysisResult, RlmConfig};
mod analysis;
mod context;
mod trace;
pub struct RlmExecutor {
pub(super) context: String,
pub(super) provider: Arc<dyn Provider>,
pub(super) model: String,
pub(super) max_iterations: usize,
pub(super) trace_steps: Vec<TraceStep>,
pub(super) context_trace: ContextTrace,
}
impl RlmExecutor {
pub fn new(context: String, provider: Arc<dyn Provider>, model: String) -> Self {
Self {
context,
provider,
model,
max_iterations: RlmConfig::default().max_iterations,
trace_steps: Vec::new(),
context_trace: ContextTrace::new(32_768),
}
}
pub fn with_max_iterations(mut self, max: usize) -> Self {
self.max_iterations = max;
self
}
pub fn with_temperature(self, _temperature: f32) -> Self {
self
}
pub fn with_verbose(self, _verbose: bool) -> Self {
self
}
pub fn trace_steps(&self) -> &[TraceStep] {
&self.trace_steps
}
pub fn context_trace_summary(&self) -> ContextTraceSummary {
self.context_trace.summary()
}
pub async fn analyze(&mut self, query: &str) -> Result<RlmAnalysisResult> {
analysis::analyze(self, query).await
}
}