use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EvaluationRequest {
pub request_id: String,
pub code: String,
pub language: String,
pub evaluation_type: EvaluationType,
pub context: Option<String>,
pub file_path: Option<String>,
}
impl EvaluationRequest {
pub fn new(code: impl Into<String>, language: impl Into<String>) -> Self {
Self {
request_id: uuid::Uuid::new_v4().to_string(),
code: code.into(),
language: language.into(),
evaluation_type: EvaluationType::Code,
context: None,
file_path: None,
}
}
pub fn with_type(mut self, eval_type: EvaluationType) -> Self {
self.evaluation_type = eval_type;
self
}
pub fn with_context(mut self, context: impl Into<String>) -> Self {
self.context = Some(context.into());
self
}
pub fn with_file_path(mut self, path: impl Into<String>) -> Self {
self.file_path = Some(path.into());
self
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum EvaluationType {
Plan,
Code,
Tests,
FinalCheck,
}
impl std::fmt::Display for EvaluationType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EvaluationType::Plan => write!(f, "plan"),
EvaluationType::Code => write!(f, "code"),
EvaluationType::Tests => write!(f, "tests"),
EvaluationType::FinalCheck => write!(f, "final_check"),
}
}
}