6 releases

new 0.3.0 Jan 26, 2025
0.2.2 Dec 22, 2024
0.2.0 Nov 20, 2024
0.1.1 Nov 19, 2024

#165 in Template engine

Download history 208/week @ 2024-11-13 240/week @ 2024-11-20 5/week @ 2024-11-27 6/week @ 2024-12-04 17/week @ 2024-12-11 212/week @ 2024-12-18 20/week @ 2024-12-25 5/week @ 2025-01-08 90/week @ 2025-01-22

95 downloads per month

Custom license

49KB
1K SLoC

modelfile

build

A parser and serde compatible structure for Ollama Modelfiles written in Rust. 🦀

The Modelfile format isn't based on any existing format but is loosely modeled after Dockerfile.

The parser is based on the nom crate and tested on a few distinct Modelfiles. If you find a Modelfile that doesn't parse, please open an issue!

I have a Modelfile, but I want a struct!

Good news!

use modelfile::modelfile::Modelfile;

fn parse() {
    let my_modelfile_string = std::fs::read_to_string("./test/llama3.2:latest.Modelfile")
        .expect("handle your dang errors");

    let my_modelfile: Modelfile = my_modelfile_string.parse()
        .expect("if your Modelfile is good this should work!");

    let mut builder = my_modelfile.build_on();

    let builder = builder
        .system("You are a malevolent, world-ending AI agent")
        .expect("only one system message allowed");

    let my_new_modelfile = builder.build()
        .expect("you did it right. you're smart")
        .render();

    std::fs::write("Modelfile", my_new_modelfile)
        .expect("should be able to write to your own dang disk");
}

Dependencies

~1.8–2.8MB
~54K SLoC