#[derive(Debug, Clone, Default)]
pub struct ModelfileBuilder {
lines: Vec<String>,
}
impl ModelfileBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn from(mut self, base_model: &str) -> Self {
self.lines.push(format!("FROM {}", base_model));
self
}
pub fn parameter(mut self, key: &str, value: &str) -> Self {
self.lines.push(format!("PARAMETER {} {}", key, value));
self
}
pub fn template(mut self, template: &str) -> Self {
self.lines.push(format!("TEMPLATE \"\"\"{}\"\"\"", template));
self
}
pub fn system(mut self, system_message: &str) -> Self {
self.lines.push(format!("SYSTEM \"\"\"{}\"\"\"", system_message));
self
}
pub fn adapter(mut self, adapter_path: &str) -> Self {
self.lines.push(format!("ADAPTER {}", adapter_path));
self
}
pub fn license(mut self, license_text: &str) -> Self {
self.lines.push(format!("LICENSE \"\"\"{}\"\"\"", license_text));
self
}
pub fn message(mut self, role: &str, content: &str) -> Self {
self.lines.push(format!("MESSAGE {} {}", role, content));
self
}
pub fn requires(mut self, version: &str) -> Self {
self.lines.push(format!("REQUIRES {}", version));
self
}
pub fn build(self) -> String {
self.lines.join("\n")
}
}