char-fork/llama.cpp

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

Aleksander Grygierui: Constants refactor (#26908)e21152dc9

char/aliceai-t5-moe
2.2 KiB52 linesraw
1import {
2	SANDBOX_TIMEOUT_MS_DEFAULT,
3	SANDBOX_TIMEOUT_MS_MAX,
4	SANDBOX_TOOL_NAME
5} from '$lib/constants';
6import { JsonSchemaType, ToolCallType } from '$lib/enums';
7import type { OpenAIToolDefinition } from '$lib/types';
8
9const NERDAMER_DESCRIPTION = `
10Symbolic/numeric math via \`nerdamer\`
11nerdamer(expr,subs?,opts?)/nerdamer.func(...)→Expression Format via .text(fmt?) (fmt: 'decimals'|'fractions'|'scientific') eval via .evaluate(subs?)
12nerdamer(expr,{x:2}) substitutes numeric via opts 'numer' or .evaluate()
13simplify/expand/factor(expr) div/gcd/lcm(...) coeffs/partfrac(expr,var)
14diff/integrate(expr,var) defint(expr,lo,hi,var?) sum/product(expr,var,lo,hi) limit(expr,var,pt)
15solve(expr,var) solveEquations([eq1,eq2],[var1,var2])
16polarform/rectform/arg/realpart/imagpart(z)
17set/get Var/Constant(name,val?) setFunction(name,[params],body)
18IMPORTANT:Identifier 'nerdamer' has already been declared, use it directly`;
19
20/**
21 * Build the sandbox tool definition. When `includeSymbolicMath` is true,
22 * the description includes nerdamer API documentation; otherwise it
23 * describes a plain JavaScript sandbox.
24 */
25export function buildSandboxToolDefinition(includeSymbolicMath: boolean): OpenAIToolDefinition {
26	return {
27		function: {
28			description: includeSymbolicMath
29				? `Execute JS in a sandboxed browser worker (no DOM/page access). Top-level await ok; console.log for intermediates; top-level return is captured as result.${NERDAMER_DESCRIPTION}`
30				: 'Execute JS in a sandboxed browser worker (no DOM/page access). Top-level await ok; console.log for intermediates; top-level return is captured as result.',
31			name: SANDBOX_TOOL_NAME,
32			parameters: {
33				properties: {
34					code: {
35						description: 'JavaScript source to execute',
36						type: JsonSchemaType.STRING
37					},
38					timeout_ms: {
39						description: `Execution timeout in milliseconds, default ${SANDBOX_TIMEOUT_MS_DEFAULT}, max ${SANDBOX_TIMEOUT_MS_MAX}`,
40						type: JsonSchemaType.NUMBER
41					}
42				},
43				required: ['code'],
44				type: JsonSchemaType.OBJECT
45			}
46		},
47		type: ToolCallType.FUNCTION
48	};
49}
50
51/** @deprecated Use {@link buildSandboxToolDefinition} instead. Kept for backward compatibility. */
52export const SANDBOX_TOOL_DEFINITION = buildSandboxToolDefinition(true);