Skip to content

Commit

Permalink
Create local-apps.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-c committed May 7, 2024
1 parent b76cf3e commit e9df990
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions packages/tasks/src/local-apps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import type { ModelData } from "./model-data";
import type { PipelineType } from "./pipelines";

/**
* Elements configurable by a local app.
*/
export type LocalApp = {
/**
* Name that appears in buttons
*/
prettyLabel: string;
/**
* Link to get more info about a local app (website etc)
*/
docsUrl: string;
/**
* main category of app
*/
mainTask: PipelineType;
/**
* Whether to display a pill "macOS-only"
*/
macOSOnly?: boolean;

comingSoon?: boolean;
/**
* IMPORTANT: function to figure out whether to display the button on a model page's main "Use this model" dropdown.
*/
displayOnModelPage: (model: ModelData) => boolean;
} & (
| {
/**
* If the app supports deeplink, URL to open.
*/
deeplink: (model: ModelData) => URL;
}
| {
/**
* And if not (mostly llama.cpp), snippet to copy/paste in your terminal
*/
snippet: (model: ModelData) => string;
}
);

function isGgufModel(model: ModelData) {
return model.tags.includes("gguf");
}

const snippetLlamacpp = (model: ModelData): string => {
return `llama-cpp \
--hf-repo ${model.id} \
-m file.gguf \
-p "I believe the meaning of life is " -n 128`;
};

/**
* Add your new local app here.
*
* This is open to new suggestions and awesome upcoming apps.
*
* /!\ IMPORTANT
*
* If possible, you need to support deeplinks and be as cross-platform as possible.
*
* Ping the HF team if we can help with anything!
*/
export const LOCAL_APPS = {
"llama.cpp": {
prettyLabel: "llama.cpp",
docsUrl: "https://github.com/ggerganov/llama.cpp",
mainTask: "text-generation",
displayOnModelPage: isGgufModel,
snippet: snippetLlamacpp,
},
lmstudio: {
prettyLabel: "LM Studio",
docsUrl: "https://lmstudio.ai",
mainTask: "text-generation",
displayOnModelPage: isGgufModel,
deeplink: (model) => new URL(`lmstudio://open_from_hf?model=${model.id}`),
},
jan: {
prettyLabel: "Jan",
docsUrl: "https://jan.ai",
mainTask: "text-generation",
displayOnModelPage: isGgufModel,
deeplink: (model) => new URL(`jan://open_from_hf?model=${model.id}`),
},
faraday: {
prettyLabel: "Faraday",
docsUrl: "https://faraday.dev",
mainTask: "text-generation",
macOSOnly: true,
displayOnModelPage: isGgufModel,
deeplink: (model) => new URL(`faraday://open_from_hf?model=${model.id}`),
},
drawthings: {
prettyLabel: "Draw Things",
docsUrl: "https://drawthings.ai",
mainTask: "text-to-image",
macOSOnly: true,
/**
* random function, will need to refine the actual conditions:
*/
displayOnModelPage: (model) => model.tags.includes("textual_inversion"),
deeplink: (model) => new URL(`drawthings://open_from_hf?model=${model.id}`),
},
diffusionbee: {
prettyLabel: "DiffusionBee",
docsUrl: "https://diffusionbee.com",
mainTask: "text-to-image",
macOSOnly: true,
comingSoon: true,
displayOnModelPage: (model) => model.library_name === "diffusers" && model.pipeline_tag === "text-to-image",
deeplink: (model) => new URL(`diffusionbee://open_from_hf?model=${model.id}`),
},
} satisfies Record<string, LocalApp>;

export type LocalAppKey = keyof typeof LOCAL_APPS;

0 comments on commit e9df990

Please sign in to comment.