Skip to content

Commit 21d6b55

Browse files
julien-cMishigmishig25
authored
[local-apps] deeplink can take an optional filepath inside the repo (#738)
Co-authored-by: Mishig <[email protected]> Co-authored-by: Mishig Davaadorj <[email protected]>
1 parent 33e0b1b commit 21d6b55

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/tasks/src/local-apps.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@ export type LocalApp = {
3232
/**
3333
* If the app supports deeplink, URL to open.
3434
*/
35-
deeplink: (model: ModelData) => URL;
35+
deeplink: (model: ModelData, filepath?: string) => URL;
3636
}
3737
| {
3838
/**
3939
* And if not (mostly llama.cpp), snippet to copy/paste in your terminal
4040
* Support the placeholder {{GGUF_FILE}} that will be replaced by the gguf file path or the list of available files.
4141
*/
42-
snippet: (model: ModelData) => string | string[];
42+
snippet: (model: ModelData, filepath?: string) => string | string[];
4343
}
4444
);
4545

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

50-
const snippetLlamacpp = (model: ModelData): string[] => {
50+
const snippetLlamacpp = (model: ModelData, filepath?: string): string[] => {
5151
return [
5252
`# Option 1: use llama.cpp with brew
5353
brew install llama.cpp
5454
5555
# Load and run the model
5656
llama \\
5757
--hf-repo "${model.id}" \\
58-
--hf-file {{GGUF_FILE}} \\
58+
--hf-file ${filepath ?? "{{GGUF_FILE}}"} \\
5959
-p "I believe the meaning of life is" \\
6060
-n 128`,
6161
`# Option 2: build llama.cpp from source with curl support
@@ -66,7 +66,7 @@ LLAMA_CURL=1 make
6666
# Load and run the model
6767
./main \\
6868
--hf-repo "${model.id}" \\
69-
-m {{GGUF_FILE}} \\
69+
-m ${filepath ?? "{{GGUF_FILE}}"} \\
7070
-p "I believe the meaning of life is" \\
7171
-n 128`,
7272
];
@@ -96,7 +96,8 @@ export const LOCAL_APPS = {
9696
docsUrl: "https://lmstudio.ai",
9797
mainTask: "text-generation",
9898
displayOnModelPage: isGgufModel,
99-
deeplink: (model) => new URL(`lmstudio://open_from_hf?model=${model.id}`),
99+
deeplink: (model, filepath) =>
100+
new URL(`lmstudio://open_from_hf?model=${model.id}` + filepath ? `&file=${filepath}` : ""),
100101
},
101102
jan: {
102103
prettyLabel: "Jan",

0 commit comments

Comments
 (0)