|
1 | 1 | import type { ModelData } from "./model-data";
|
2 | 2 | import type { PipelineType } from "./pipelines";
|
3 | 3 |
|
| 4 | +export interface LocalAppSnippet { |
| 5 | + /** |
| 6 | + * Title of the snippet |
| 7 | + */ |
| 8 | + title: string; |
| 9 | + /** |
| 10 | + * Optional setup guide |
| 11 | + */ |
| 12 | + setup?: string; |
| 13 | + /** |
| 14 | + * Content (or command) to be run |
| 15 | + */ |
| 16 | + content: string; |
| 17 | +} |
| 18 | + |
4 | 19 | /**
|
5 | 20 | * Elements configurable by a local app.
|
6 | 21 | */
|
@@ -39,36 +54,48 @@ export type LocalApp = {
|
39 | 54 | * And if not (mostly llama.cpp), snippet to copy/paste in your terminal
|
40 | 55 | * Support the placeholder {{GGUF_FILE}} that will be replaced by the gguf file path or the list of available files.
|
41 | 56 | */
|
42 |
| - snippet: (model: ModelData, filepath?: string) => string | string[]; |
| 57 | + snippet: (model: ModelData, filepath?: string) => string | string[] | LocalAppSnippet | LocalAppSnippet[]; |
43 | 58 | }
|
44 | 59 | );
|
45 | 60 |
|
46 | 61 | function isGgufModel(model: ModelData) {
|
47 | 62 | return model.tags.includes("gguf");
|
48 | 63 | }
|
49 | 64 |
|
50 |
| -const snippetLlamacpp = (model: ModelData, filepath?: string): string[] => { |
| 65 | +const snippetLlamacpp = (model: ModelData, filepath?: string): LocalAppSnippet[] => { |
| 66 | + const command = (binary: string) => |
| 67 | + [ |
| 68 | + "# Load and run the model:", |
| 69 | + `${binary} \\`, |
| 70 | + ` --hf-repo "${model.id}" \\`, |
| 71 | + ` --hf-file ${filepath ?? "{{GGUF_FILE}}"} \\`, |
| 72 | + ' -p "You are a helpful assistant" \\', |
| 73 | + " --conversation", |
| 74 | + ].join("\n"); |
51 | 75 | return [
|
52 |
| - `# Option 1: use llama.cpp with brew |
53 |
| -brew install llama.cpp |
54 |
| -
|
55 |
| -# Load and run the model |
56 |
| -llama \\ |
57 |
| - --hf-repo "${model.id}" \\ |
58 |
| - --hf-file ${filepath ?? "{{GGUF_FILE}}"} \\ |
59 |
| - -p "I believe the meaning of life is" \\ |
60 |
| - -n 128`, |
61 |
| - `# Option 2: build llama.cpp from source with curl support |
62 |
| -git clone https://github.com/ggerganov/llama.cpp.git |
63 |
| -cd llama.cpp |
64 |
| -LLAMA_CURL=1 make |
65 |
| -
|
66 |
| -# Load and run the model |
67 |
| -./main \\ |
68 |
| - --hf-repo "${model.id}" \\ |
69 |
| - -m ${filepath ?? "{{GGUF_FILE}}"} \\ |
70 |
| - -p "I believe the meaning of life is" \\ |
71 |
| - -n 128`, |
| 76 | + { |
| 77 | + title: "Install from brew", |
| 78 | + setup: "brew install llama.cpp", |
| 79 | + content: command("llama-cli"), |
| 80 | + }, |
| 81 | + { |
| 82 | + title: "Use pre-built binary", |
| 83 | + setup: [ |
| 84 | + // prettier-ignore |
| 85 | + "# Download pre-built binary from:", |
| 86 | + "# https://github.com/ggerganov/llama.cpp/releases", |
| 87 | + ].join("\n"), |
| 88 | + content: command("./llama-cli"), |
| 89 | + }, |
| 90 | + { |
| 91 | + title: "Build from source code", |
| 92 | + setup: [ |
| 93 | + "git clone https://github.com/ggerganov/llama.cpp.git", |
| 94 | + "cd llama.cpp", |
| 95 | + "LLAMA_CURL=1 make llama-cli", |
| 96 | + ].join("\n"), |
| 97 | + content: command("./llama-cli"), |
| 98 | + }, |
72 | 99 | ];
|
73 | 100 | };
|
74 | 101 |
|
|
0 commit comments