-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |