Skip to content

Commit b542b53

Browse files
authored
feat: download models using the CLI (#191)
1 parent 6267778 commit b542b53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2957
-830
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ body:
3939
Your bug can be investigated much faster if your code can be run without any dependencies other than `node-llama-cpp`.
4040
Issues without reproduction steps or code examples may be closed as not actionable.
4141
Please try to provide a Minimal, Complete, and Verifiable example ([link](http://stackoverflow.com/help/mcve)).
42+
Also, please enable enable debug logs by using `getLlama({logLevel: LlamaLogLevel.debug})` to get more information.
4243
placeholder: >-
4344
Please try to provide a Minimal, Complete, and Verifiable example.
4445
http://stackoverflow.com/help/mcve

.vitepress/utils/getCommandHtmlDoc.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {htmlEscape} from "./htmlEscape.js";
33
import {cliBinName, npxRunPrefix} from "../../src/config.js";
44
import {buildHtmlTable} from "./buildHtmlTable.js";
55
import {buildHtmlHeading} from "./buildHtmlHeading.js";
6+
import {htmlEscapeWithCodeMarkdown} from "./htmlEscapeWithCodeMarkdown.js";
67

78
export async function getCommandHtmlDoc(command: CommandModule<any, any>, {
89
cliName = cliBinName,
@@ -45,7 +46,7 @@ export async function getCommandHtmlDoc(command: CommandModule<any, any>, {
4546

4647
return [
4748
`<a href="${subCommandsParentPageLink != null ? (subCommandsParentPageLink + "/") : ""}${commandPageLink}"><code>` + htmlEscape(cliName + " " + cliCommand) + "</code></a>",
48-
htmlEscape(String(subCommand.describe ?? ""))
49+
htmlEscapeWithCodeMarkdown(String(subCommand.describe ?? ""))
4950
];
5051
})
5152
.filter((row): row is string[] => row != null)
@@ -61,7 +62,7 @@ export async function getCommandHtmlDoc(command: CommandModule<any, any>, {
6162
for (const group of optionGroups) {
6263
let groupName = group.name;
6364
if (groupName !== "default") {
64-
res += buildHtmlHeading("h3", htmlEscape(groupName), encodeURIComponent(groupName.toLowerCase()));
65+
res += buildHtmlHeading("h3", htmlEscapeWithCodeMarkdown(groupName), encodeURIComponent(groupName.toLowerCase()));
6566
}
6667

6768
res += renderOptionsGroupOptionsTable(group.options) + "\n";
@@ -207,7 +208,7 @@ function renderOptionsGroupOptionsTable(options: {name: string, option: Options}
207208
}
208209
}
209210

210-
let optionDescription: string[] = option.description != null ? [htmlEscape(option.description)] : [];
211+
let optionDescription: string[] = option.description != null ? [htmlEscapeWithCodeMarkdown(option.description)] : [];
211212

212213
const hasDefaultDescription = option.defaultDescription != null && option.defaultDescription.trim().length > 0;
213214
if (option.default != null || hasDefaultDescription) {
@@ -218,7 +219,7 @@ function renderOptionsGroupOptionsTable(options: {name: string, option: Options}
218219
}
219220

220221
if (option.type != null) {
221-
optionDescription.push(`<code><span style="opacity: 0.4">(</span>${htmlEscape(option.type)}<span style="opacity: 0.4">)</span></code>`);
222+
optionDescription.push(`<code><span style="opacity: 0.4">(</span>${htmlEscape(option.type + (option.array ? "[]" : ""))}<span style="opacity: 0.4">)</span></code>`);
222223
}
223224

224225
if (option.demandOption) {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {htmlEscape} from "./htmlEscape.js";
2+
3+
export function htmlEscapeWithCodeMarkdown(string?: string | number | boolean) {
4+
const escapedString = htmlEscape(string);
5+
6+
let res = ""
7+
let backtickIndex = escapedString.indexOf("`");
8+
let textIndex = 0;
9+
10+
while (backtickIndex >= 0 && backtickIndex < escapedString.length - 1 && textIndex < escapedString.length) {
11+
const nextBacktickIndex = escapedString.indexOf("`", backtickIndex + 1);
12+
if (nextBacktickIndex < 0)
13+
break;
14+
15+
res += escapedString.slice(textIndex, backtickIndex) + "<code>" + escapedString.slice(backtickIndex + 1, nextBacktickIndex) + "</code>";
16+
textIndex = nextBacktickIndex + 1;
17+
18+
if (textIndex < escapedString.length)
19+
backtickIndex = escapedString.indexOf("`", textIndex);
20+
}
21+
22+
res += escapedString.slice(textIndex);
23+
24+
return res;
25+
}
26+

docs/guide/cli/cli.data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {buildHtmlHeading} from "../../../.vitepress/utils/buildHtmlHeading.js";
1515
import {buildHtmlTable} from "../../../.vitepress/utils/buildHtmlTable.js";
1616
import {setIsInDocumentationMode} from "../../../src/state.js";
1717
import {InspectMeasureCommand} from "../../../src/cli/commands/inspect/commands/InspectMeasureCommand.js";
18+
import {htmlEscapeWithCodeMarkdown} from "../../../.vitepress/utils/htmlEscapeWithCodeMarkdown.js";
1819

1920
export default {
2021
async load() {
@@ -71,7 +72,7 @@ function buildIndexTable(commands: [pageLink: string, command: CommandModule<any
7172

7273
return [
7374
`<a href="${pageLink}"><code>` + htmlEscape(cliName + " " + command.command) + "</code></a>",
74-
htmlEscape(String(command.describe ?? ""))
75+
htmlEscapeWithCodeMarkdown(String(command.describe ?? ""))
7576
];
7677
})
7778
.filter((row): row is string[] => row != null)

0 commit comments

Comments
 (0)