char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Improve Chat Messages rendering performance (#28460)0afb805b1

char/aliceai-t5-moe
1.0 KiB23 linesraw
1// Tool-args and tool-result parsing helpers: the file tools' path field
2// aliases, the JSON container gates for result blobs, and the targeted
3// string-field pattern used for cheap title-tier extraction.
4
5/**
6 * Field aliases the file tools accept for the path argument. Tool contracts
7 * drifted over time: some models emit `file_path` / `filePath`.
8 */
9export const TOOL_ARG_PATH_KEYS: readonly string[] = ['path', 'file_path', 'filePath'];
10
11/** Opening character of a JSON object; only an object root can carry fields. */
12export const JSON_OBJECT_OPEN = '{';
13
14/** Opening character of a JSON array; successful sandbox output is one. */
15export const JSON_ARRAY_OPEN = '[';
16
17/**
18 * Matches `"<key>": "<value>"` in a JSON args blob ( whitespace between
19 * tokens allowed ), capturing the raw string literal so only that literal
20 * gets decoded; escaped quotes stay inside the value group. `{key}` is
21 * replaced with the field name before use.
22 */
23export const TOOL_ARG_STRING_FIELD_PATTERN_TEMPLATE = '"{key}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"';