-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_basic.mjs
More file actions
38 lines (30 loc) · 879 Bytes
/
chat_basic.mjs
File metadata and controls
38 lines (30 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict';
import util from './util.mjs';
const { postJSON, getJSON } = util;
async function main() {
console.log('Health:', await getJSON('/healthz'));
console.log('Loading GGUF model via HF repo + file...');
const load = await postJSON('/load_gguf', {
hf_repo: 'unsloth/Qwen3-1.7B-GGUF',
hf_file: 'Qwen3-1.7B-Q8_0.gguf',
n_ctx: 4096,
chat_format: 'chatml',
});
console.log('Loaded:', load);
const messages = [
{ role: 'system', content: 'You are helpful.' },
{ role: 'user', content: 'Write a haiku about GPUs.' },
];
const resp = await postJSON('/chat', {
messages,
max_tokens: 128,
temperature: 0.7,
});
console.log('Chat response:', resp.content);
console.log('Unloading model...');
console.log(await postJSON('/unload_gguf', {}));
}
main().catch((err) => {
console.error(err);
process.exit(1);
});