Skip to content

Commit

Permalink
[local-apps] deeplink can take an optional filepath inside the repo (
Browse files Browse the repository at this point in the history
…#738)

Co-authored-by: Mishig <[email protected]>
Co-authored-by: Mishig Davaadorj <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent 33e0b1b commit 21d6b55
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/tasks/src/local-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@ export type LocalApp = {
/**
* If the app supports deeplink, URL to open.
*/
deeplink: (model: ModelData) => URL;
deeplink: (model: ModelData, filepath?: string) => URL;
}
| {
/**
* And if not (mostly llama.cpp), snippet to copy/paste in your terminal
* Support the placeholder {{GGUF_FILE}} that will be replaced by the gguf file path or the list of available files.
*/
snippet: (model: ModelData) => string | string[];
snippet: (model: ModelData, filepath?: string) => string | string[];
}
);

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

const snippetLlamacpp = (model: ModelData): string[] => {
const snippetLlamacpp = (model: ModelData, filepath?: string): string[] => {
return [
`# Option 1: use llama.cpp with brew
brew install llama.cpp
# Load and run the model
llama \\
--hf-repo "${model.id}" \\
--hf-file {{GGUF_FILE}} \\
--hf-file ${filepath ?? "{{GGUF_FILE}}"} \\
-p "I believe the meaning of life is" \\
-n 128`,
`# Option 2: build llama.cpp from source with curl support
Expand All @@ -66,7 +66,7 @@ LLAMA_CURL=1 make
# Load and run the model
./main \\
--hf-repo "${model.id}" \\
-m {{GGUF_FILE}} \\
-m ${filepath ?? "{{GGUF_FILE}}"} \\
-p "I believe the meaning of life is" \\
-n 128`,
];
Expand Down Expand Up @@ -96,7 +96,8 @@ export const LOCAL_APPS = {
docsUrl: "https://lmstudio.ai",
mainTask: "text-generation",
displayOnModelPage: isGgufModel,
deeplink: (model) => new URL(`lmstudio://open_from_hf?model=${model.id}`),
deeplink: (model, filepath) =>
new URL(`lmstudio://open_from_hf?model=${model.id}` + filepath ? `&file=${filepath}` : ""),
},
jan: {
prettyLabel: "Jan",
Expand Down

0 comments on commit 21d6b55

Please sign in to comment.