Skip to content
35 changes: 28 additions & 7 deletions packages/tasks/src/local-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ function isLlamaCppGgufModel(model: ModelData) {
return !!model.gguf?.context_length;
}

function isAmdRyzenModel(model: ModelData) {
return model.tags.includes("ryzenai-hybrid") || model.tags.includes("ryzenai-npu");
}

function isMlxModel(model: ModelData) {
return model.tags.includes("mlx");
}
Expand Down Expand Up @@ -317,21 +321,38 @@ const snippetDockerModelRunner = (model: ModelData, filepath?: string): string =

const snippetLemonade = (model: ModelData, filepath?: string): LocalAppSnippet[] => {
const tagName = getQuantTag(filepath);
const modelName = model.id.split("/")[1];
const modelName = model.id.includes("/") ? model.id.split("/")[1] : model.id;

// Get recipe according to model type
let simplifiedModelName: string;
let recipe: string;
let checkpoint: string;
let requirements: string;
if (model.tags.some((tag) => ["ryzenai-npu", "ryzenai-hybrid"].includes(tag))) {
recipe = model.tags.includes("ryzenai-npu") ? "oga-npu" : "oga-hybrid";
checkpoint = model.id;
requirements = " (requires RyzenAI 300 series)";
simplifiedModelName = modelName.split("-awq-")[0];
simplifiedModelName += recipe === "oga-npu" ? "-NPU" : "-Hybrid";
} else {
recipe = "llamacpp";
checkpoint = `${model.id}${tagName}`;
requirements = "";
simplifiedModelName = modelName;
}

return [
{
title: "Pull the model",
setup: "# Download Lemonade from https://lemonade-server.ai/",
content: [
`lemonade-server pull user.${modelName} \\
--checkpoint ${model.id}${tagName} \\
--recipe llamacpp`,
`lemonade-server pull user.${simplifiedModelName} --checkpoint ${checkpoint} --recipe ${recipe}`,
"# Note: If you installed from source, use the lemonade-server-dev command instead.",
].join("\n"),
},
{
title: "Run and chat with the model",
content: `lemonade-server run user.${modelName}`,
title: `Run and chat with the model${requirements}`,
content: `lemonade-server run user.${simplifiedModelName}`,
},
{
title: "List all available models",
Expand Down Expand Up @@ -521,7 +542,7 @@ export const LOCAL_APPS = {
prettyLabel: "Lemonade",
docsUrl: "https://lemonade-server.ai",
mainTask: "text-generation",
displayOnModelPage: isLlamaCppGgufModel,
displayOnModelPage: (model) => isLlamaCppGgufModel(model) || isAmdRyzenModel(model),
snippet: snippetLemonade,
},
} satisfies Record<string, LocalApp>;
Expand Down
Loading