Skip to content

Commit 5331d07

Browse files
committed
feat: structured snippet
1 parent cbdc495 commit 5331d07

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

packages/tasks/src/local-apps.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import type { ModelData } from "./model-data";
22
import type { PipelineType } from "./pipelines";
33

4+
/**
5+
* Code snippet to display
6+
* Support placeholders in the form of {{key}} in content
7+
* where key is a key in the params object
8+
*/
9+
export interface Snippet {
10+
content: string;
11+
language?: "javascript" | "json" | "python" | "bash" | "jboss-cli" | "markdown" | "xml";
12+
parameters?: Record<string, string[]>;
13+
}
14+
415
/**
516
* Elements configurable by a local app.
617
*/
@@ -38,28 +49,32 @@ export type LocalApp = {
3849
/**
3950
* And if not (mostly llama.cpp), snippet to copy/paste in your terminal
4051
*/
41-
snippet: (model: ModelData) => string | string[];
52+
snippet: (model: ModelData) => Snippet | Snippet[];
4253
}
4354
);
4455

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

49-
const snippetLlamacpp = (model: ModelData): string[] => {
60+
const snippetLlamacpp = (model: ModelData): Snippet[] => {
5061
return [
51-
`
52-
## Install and build llama.cpp with curl support
62+
{
63+
content: `## Install and build llama.cpp with curl support
5364
git clone https://github.com/ggerganov/llama.cpp.git
5465
cd llama.cpp
5566
LLAMA_CURL=1 make
5667
`,
57-
`## Load and run the model
68+
},
69+
{
70+
content: `## Load and run the model
5871
./main \\
5972
--hf-repo "${model.id}" \\
6073
-m {{GGUF_FILE}} \\
6174
-p "I believe the meaning of life is" \\
6275
-n 128`,
76+
parameters: { GGUF_FILE: model.ggufFilePaths ?? [] },
77+
},
6378
];
6479
};
6580

packages/tasks/src/model-data.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ export interface ModelData {
123123
* Example: transformers, SpeechBrain, Stanza, etc.
124124
*/
125125
library_name?: string;
126+
127+
ggufFilePaths?: string[];
126128
}
127129

128130
/**

0 commit comments

Comments
 (0)