Skip to content
17 changes: 17 additions & 0 deletions packages/tasks/src/local-apps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ModelData } from "./model-data";
import type { PipelineType } from "./pipelines";
import { parseGGUFQuantLabel } from "@huggingface/gguf";

export interface LocalAppSnippet {
/**
Expand Down Expand Up @@ -143,6 +144,15 @@ const snippetNodeLlamaCppCli = (model: ModelData, filepath?: string): LocalAppSn
];
};

const snippetOllama = (model: ModelData, filepath?: string): string => {
if (filepath) {
const quantLabel = parseGGUFQuantLabel(filepath);
const ollamatag = quantLabel ? `:${quantLabel}` : "";
return `ollama run hf.co/${model.id}${ollamatag}`;
}
return `ollama run hf.co/${model.id}{{OLLAMA_TAG}}`;
};

const snippetLocalAI = (model: ModelData, filepath?: string): LocalAppSnippet[] => {
const command = (binary: string) =>
["# Load and run the model:", `${binary} huggingface://${model.id}/${filepath ?? "{{GGUF_FILE}}"}`].join("\n");
Expand Down Expand Up @@ -389,6 +399,13 @@ export const LOCAL_APPS = {
displayOnModelPage: (model) => model.library_name === "diffusers" && model.pipeline_tag === "text-to-image",
deeplink: (model) => new URL(`https://models.invoke.ai/huggingface/${model.id}`),
},
ollama: {
prettyLabel: "Ollama",
docsUrl: "https://ollama.com",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably have dedicated docs on the hub for this, but we can make a follow-up PR later on

mainTask: "text-generation",
displayOnModelPage: (model) => model.tags.includes("conversational") && isLlamaCppGgufModel(model),
snippet: snippetOllama,
},
} satisfies Record<string, LocalApp>;

export type LocalAppKey = keyof typeof LOCAL_APPS;
Loading