Skip to content

add llamafile 🦙📁 #866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/tasks/src/local-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,32 @@ const snippetTgi = (model: ModelData): LocalAppSnippet[] => {
];
};

const snippetLlamafile = (model: ModelData, filepath?: string): LocalAppSnippet[] => {
const modelFile = filepath ?? "{{GGUF_FILE}}";
const command = (binary: string) => {
const snippet = ["# Load and run the model:", `${binary} -m ${modelFile}`];
if (!model.tags.includes("conversational")) {
snippet.push('-p "Once upon a time,"');
}
return snippet.join("\n");
};

return [
{
title: "Use pre-built binary",
setup: [
"# Download llamafile binary and rename it to llamafile.exe from:",
"# https://github.com/Mozilla-Ocho/llamafile/releases/latest",
"# Make the binary executable:",
"chmod +x ./llamafile.exe",
"# Download the model:",
`wget https://huggingface.co/${model.id}/resolve/main/${modelFile}`,
].join("\n"),
content: command("./llamafile.exe"),
},
];
};

/**
* Add your new local app here.
*
Expand Down Expand Up @@ -430,6 +456,13 @@ export const LOCAL_APPS = {
displayOnModelPage: isLlamaCppGgufModel,
snippet: snippetOllama,
},
llamafile: {
prettyLabel: "llamafile",
docsUrl: "https://github.com/Mozilla-Ocho/llamafile",
mainTask: "text-generation",
displayOnModelPage: isLlamaCppGgufModel,
snippet: snippetLlamafile,
},
} satisfies Record<string, LocalApp>;

export type LocalAppKey = keyof typeof LOCAL_APPS;