Path: redb-route/redb.Route.Llm.Tools/MathEvalTool.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm.Tools/MathEvalTool.cs ---- using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Llm.Abstractions.Tools; using redb.Route.Llm.Extensions; namespace redb.Route.Llm.Tools; /// /// Standalone RouteBuilder wrapper that mounts /// behind a tool route. Prefer the /// DSL extension .MathEval(opts) on any existing route — this shim is /// only useful when you want a self-contained RouteBuilder to hand to /// context.AddRoutes(...). /// public sealed class MathEvalTool : RouteBuilder { private const string InputSchema = """ { "type": "object", "properties": { "expression": { "type": "string", "description": "Value expression supported by redb.Route's ExpressionResolver, e.g. '2 * (3 + 4)' or 'property.x + 1'." } }, "required": ["expression"], "additionalProperties": false } """; private readonly MathEvalOptions _options; /// Creates the tool with default options. public MathEvalTool() : this(new MathEvalOptions()) { } /// Creates the tool with the given options. public MathEvalTool(MathEvalOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); } /// protected override void Configure() => From(_options.EndpointUri) .AsLlmTool(_options.ToolName) .Description("Evaluates a value expression via redb.Route's ExpressionResolver " + "(arithmetic, comparisons, ternary, jpath/property/header/body refs). " + "Returns the result as JSON.") .Input(InputSchema) .SideEffect(ToolSideEffect.ReadOnly) .Cost(ToolCostClass.Cheap) .Then() .MathEval(_options); }