Skip to content

Commit 7805fd5

Browse files
authored
docs: improve documentation (#324)
1 parent 6c644ff commit 7805fd5

File tree

12 files changed

+75
-10
lines changed

12 files changed

+75
-10
lines changed

.vitepress/components/BlogEntry/BlogEntry.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const dateText = new Date(props.date).toLocaleDateString("en-US", {
4747
}"
4848
/>
4949
</a>
50-
<p class="description">{{ props.description }}</p>
50+
<p class="description" v-html="props.description"></p>
5151
<a class="readMore" :href="withBase(props.link)">
5252
Read more
5353
<span class="vpi-arrow-right"></span>

.vitepress/components/HomePage/HomePage.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ getElectronExampleAppDownloadLink()
244244
}
245245
}
246246
247+
:global(.VPHome .VPHero .container .main) {
248+
&:global(>.name) {
249+
font-weight: 701;
250+
}
251+
252+
&:global(>.text) {
253+
font-weight: 699;
254+
}
255+
}
256+
247257
:global(html.start-animation) {
248258
.content {
249259
transition: opacity 0.5s 0.25s, transform 0.5s 0.25s, translate 0.5s, display 1s ease-in-out;
@@ -292,7 +302,7 @@ getElectronExampleAppDownloadLink()
292302
}
293303
}
294304
295-
&:global(> .text) {
305+
&:global(>.text) {
296306
transition: font-weight 0.5s ease-in-out;
297307
298308
@starting-style {
@@ -301,7 +311,7 @@ getElectronExampleAppDownloadLink()
301311
}
302312
}
303313
304-
&:global(> .tagline) {
314+
&:global(>.tagline) {
305315
transition: transform 0.5s ease-in-out;
306316
307317
@starting-style {

.vitepress/config.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,22 @@ export default defineConfig({
324324
search: {
325325
provider: "local",
326326
options: {
327-
detailedView: true
327+
detailedView: true,
328+
miniSearch: {
329+
searchOptions: {
330+
boostDocument(term, documentId, storedFields) {
331+
const firstTitle = (storedFields?.titles as string[])?.[0];
332+
if (firstTitle?.startsWith("Type Alias: "))
333+
return -0.8;
334+
else if (firstTitle?.startsWith("Class: "))
335+
return -0.9;
336+
else if (firstTitle?.startsWith("Function: "))
337+
return -0.95;
338+
339+
return 1;
340+
}
341+
}
342+
}
328343
}
329344
},
330345
sidebar: {

.vitepress/theme/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,10 @@ html.blog-page .vp-doc h2 {
547547
border-top: none;
548548
}
549549

550+
html.blog-page .vp-doc>div>hr:first-of-type {
551+
display: none;
552+
}
553+
550554
/*#VPContent {*/
551555
/* background-image: radial-gradient(1200px 380px at 50% 0%, color-mix(in srgb, var(--vp-c-brand-1) 32%, transparent), transparent 64%);*/
552556
/*}*/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* A Complete suite of everything you need to use LLMs in your projects
2626
* [Use the CLI to chat with a model without writing any code](#try-it-without-installing)
2727
* Up-to-date with the latest `llama.cpp`. Download and compile the latest release with a [single CLI command](https://node-llama-cpp.withcat.ai//guide/building-from-source#downloading-a-release)
28-
* Force a model to generate output in a parseable format, [like JSON](https://node-llama-cpp.withcat.ai/guide/chat-session#json-response), or even force it to [follow a specific JSON schema](https://node-llama-cpp.withcat.ai/guide/chat-session#response-json-schema)
28+
* Enforce a model to generate output in a parseable format, [like JSON](https://node-llama-cpp.withcat.ai/guide/chat-session#json-response), or even force it to [follow a specific JSON schema](https://node-llama-cpp.withcat.ai/guide/chat-session#response-json-schema)
2929
* [Provide a model with functions it can call on demand](https://node-llama-cpp.withcat.ai/guide/chat-session#function-calling) to retrieve information of perform actions
3030
* [Embedding support](https://node-llama-cpp.withcat.ai/guide/embedding)
3131
* Great developer experience with full TypeScript support, and [complete documentation](https://node-llama-cpp.withcat.ai/guide/)

docs/blog/blog.data.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {createContentLoader} from "vitepress";
22
import {ensureLocalImage} from "../../.vitepress/utils/ensureLocalImage.js";
3+
import {htmlEscape} from "../../.vitepress/utils/htmlEscape.js";
34

45
const loader = {
56
async load() {
@@ -17,7 +18,11 @@ const loader = {
1718
return {
1819
title: post.frontmatter.title as string | undefined,
1920
date: post.frontmatter.date as string | undefined,
20-
description: post.excerpt || post.frontmatter.description as string | undefined,
21+
description: post.excerpt || (
22+
(post.frontmatter.description as string | undefined) != null
23+
? htmlEscape(post.frontmatter.description as string)
24+
: undefined
25+
),
2126
link: post.url,
2227
image: await getImage(
2328
typeof post.frontmatter.image === "string"

docs/guide/Metal.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and when building from source on macOS on Apple Silicon Macs, Metal support is e
88

99
`llama.cpp` doesn't support Metal well on Intel Macs, so it is disabled by default on those machines.
1010

11+
<div class="info custom-block" style="padding-top: 8px">
12+
13+
[Accelerate framework](https://developer.apple.com/accelerate/) is always enabled on Mac.
14+
15+
</div>
16+
1117
## Toggling Metal Support {#building}
1218
### Prerequisites
1319
* [`cmake-js` dependencies](https://github.com/cmake-js/cmake-js#:~:text=projectRoot/build%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bstring%5D-,Requirements%3A,-CMake)

docs/guide/chat-session.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,30 @@ console.log("AI: " + res);
534534
```
535535

536536
## Complete User Prompt {#complete-prompt}
537+
538+
<script setup lang="ts">
539+
import {withBase} from "vitepress";
540+
import {ref} from "vue";
541+
import {
542+
defaultDownloadElectronExampleAppLink,
543+
getElectronExampleAppDownloadLink
544+
} from "../../.vitepress/components/HomePage/utils/getElectronExampleAppDownloadLink.js";
545+
546+
const downloadElectronExampleAppLink = ref<string>(defaultDownloadElectronExampleAppLink);
547+
548+
getElectronExampleAppDownloadLink()
549+
.then((link) => {
550+
downloadElectronExampleAppLink.value = link;
551+
});
552+
</script>
553+
554+
<div class="info custom-block" style="padding-top: 8px;">
555+
556+
You can try this feature in the <a target="_blank" :href="downloadElectronExampleAppLink">example Electron app</a>.
557+
Just type a prompt and see the completion generated by the model.
558+
559+
</div>
560+
537561
You can generate a completion to a given incomplete user prompt and let the model complete it.
538562

539563
The advantage of doing that on the chat session is that it will use the chat history as context for the completion,

docs/guide/grammar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Using Grammar
2-
Use this to force a model to generate response in a specific format of text, like `JSON` for example.
2+
Use this to enforce a model to generate response in a specific format of text, like `JSON` for example.
33

44
::: tip NOTE
55

docs/guide/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ as well as balances the default settings to get the best performance from your h
3939
No need to manually configure anything.
4040

4141
**Metal:** Enabled by default on Macs with Apple Silicon. If you're using a Mac with an Intel chip, [you can manually enable it](./Metal.md).
42+
[Accelerate framework](https://developer.apple.com/accelerate/) is always enabled.
4243

4344
**CUDA:** Used by default when support is detected. For more details, see the [CUDA guide](./CUDA.md).
4445

@@ -126,7 +127,7 @@ console.log("AI: " + a2);
126127
127128

128129
### Chatbot With JSON Schema {#chatbot-with-json-schema}
129-
To force a model to generate output according to a JSON schema, use [`llama.createGrammarForJsonSchema()`](../api/classes/Llama.md#creategrammarforjsonschema).
130+
To enforce a model to generate output according to a JSON schema, use [`llama.createGrammarForJsonSchema()`](../api/classes/Llama.md#creategrammarforjsonschema).
130131

131132
It'll force the model to generate output according to the JSON schema you provide, and it'll do it on the text generation level.
132133

0 commit comments

Comments
 (0)