@qvac/llm-llamacpp 0.58.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,8 @@ This native C++ addon, built using the `Bare` Runtime, simplifies running Large
14
14
  - [4. Create Model Instance](#4-create-model-instance)
15
15
  - [5. Load Model](#5-load-model)
16
16
  - [6. Run Inference](#6-run-inference)
17
+ - [Tool calling](#tool-calling)
18
+ - [Batch inference](#batch-inference)
17
19
  - [7. Release Resources](#7-release-resources)
18
20
  - [API behavior by state](#api-behavior-by-state)
19
21
  - [Assessing fit](#assessing-fit)
@@ -295,6 +297,26 @@ try {
295
297
 
296
298
  When `opts.stats` is enabled, `response.stats` includes runtime metrics such as `TTFT`, `TPS`, token counters, and `backendDevice` (`"cpu"` or `"gpu"`). `backendDevice` reflects the resolved device used at runtime after backend selection/fallback logic, not only the requested config.
297
299
 
300
+ #### Tool calling
301
+
302
+ Load with `config.tools: 'true'` and declare tools as `{ type: 'function', ... }` entries in the message array. The model answers a tool request with a tool-call block in its own format (`<tool_call>` for Qwen). To continue the conversation, put the call on an assistant turn as `tool_calls` and the result on a `tool` turn; the chat template renders both natively, so neither needs to be written into `content`.
303
+
304
+ ```javascript
305
+ const response = await model.run([
306
+ {
307
+ type: 'function',
308
+ name: 'get_weather',
309
+ description: 'Get the weather for a city',
310
+ parameters: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] }
311
+ },
312
+ { role: 'user', content: 'Weather in Paris?' },
313
+ { role: 'assistant', content: '', tool_calls: [{ id: 'call_1', name: 'get_weather', arguments: { city: 'Paris' } }] },
314
+ { role: 'tool', content: '18C', tool_call_id: 'call_1', name: 'get_weather' }
315
+ ])
316
+ ```
317
+
318
+ `arguments` is an object or the text of a JSON object, and `content` may be empty on the assistant turn. A malformed tool turn is rejected with `InvalidInputFormat`. [`examples/toolCalling.js`](./examples/toolCalling.js) shows a full round trip.
319
+
298
320
  #### Batch inference
299
321
 
300
322
  Load the model with `parallel >= 2`, then pass an array of prompts. Each chunk arrives tagged with the id of the sequence that produced it; `await()` returns results in input order.
package/index.d.ts CHANGED
@@ -375,8 +375,23 @@ declare namespace LlmLlamacpp {
375
375
  */
376
376
  reasoning_content?: string;
377
377
  type?: undefined;
378
+ /**
379
+ * Tool calls this assistant turn made, rendered by the chat template in
380
+ * the model's own tool-call format. `arguments` is an object or the text
381
+ * of a JSON object. `content` may be empty on such a turn.
382
+ */
383
+ tool_calls?: ToolCallTurn[];
384
+ /** On a `tool` turn: the id of the call this result answers. */
385
+ tool_call_id?: string;
386
+ /** On a `tool` turn: the name of the tool that produced the result. */
387
+ name?: string;
378
388
  [key: string]: any;
379
389
  }
390
+ interface ToolCallTurn {
391
+ id?: string;
392
+ name: string;
393
+ arguments?: string | Record<string, unknown>;
394
+ }
380
395
  interface UserMediaMessage {
381
396
  role: "user";
382
397
  type: "media";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/llm-llamacpp",
3
- "version": "0.58.0",
3
+ "version": "0.59.0",
4
4
  "description": "llama addon for qvac",
5
5
  "addon": true,
6
6
  "scripts": {
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.58"
10
+ "version": "0.59"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.58"
10
+ "version": "0.59"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.58"
10
+ "version": "0.59"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.58"
10
+ "version": "0.59"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [
@@ -7,7 +7,7 @@
7
7
  ],
8
8
  "current_versions": [
9
9
  {
10
- "version": "0.58"
10
+ "version": "0.59"
11
11
  }
12
12
  ],
13
13
  "exported_symbols": [