use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use serde_json::{json, Value};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaskDefinition {
pub name: String,
pub parameters: HashMap<String, serde_json::Value>,
}
impl TaskDefinition {
pub fn new(name: impl Into<String>) -> Self {
TaskDefinition {
name: name.into(),
parameters: HashMap::new(),
}
}
pub fn with_param(mut self, key: impl Into<String>, value: impl Into<Value>) -> Self {
self.parameters.insert(key.into(), value.into());
self
}
pub fn with_max_tokens(self, tokens: u32) -> Self {
self.with_param("max_tokens", json!(tokens))
}
pub fn with_temperature(self, temp: f32) -> Self {
self.with_param("temperature", json!(temp))
}
}