Files
enkly-ai/services/agent/internal/infrastructure/toolexec/mlmath.go
enkly 79ce8dc4c0
Some checks failed
Go CI Pipeline / build_and_test (push) Failing after 22m0s
Init Project
2026-10-30 18:06:55 +01:00

30 lines
1.1 KiB
Go

package toolexec
import (
"enkly/pkg/mathkit"
"enkly/pkg/vllmkit"
)
// solveMLMath runs the solve_ml_math tool. Like write_todos, this is
// pure, in-memory computation (arithmetic over the arguments the
// model already supplied) with no filesystem, database, or other
// service dependency, so — unlike every tool in executor.go that
// calls out to the workspace or knowledge service — it never leaves
// this process. See pkg/mathkit/solve.go for the operation dispatch
// table and pkg/mathkit's package doc for the math it covers.
func solveMLMath(call vllmkit.ToolCallRequest) vllmkit.ToolResult {
op := argStr(call.Arguments, "operation")
if op == "" {
return vllmkit.ToolResult{
Name: call.Name,
Content: `solve_ml_math: missing "operation" — see the tool description for the full list of supported operations`,
IsError: true,
}
}
result, err := mathkit.Solve(op, call.Arguments)
if err != nil {
return vllmkit.ToolResult{Name: call.Name, Content: "solve_ml_math: " + err.Error(), IsError: true}
}
return vllmkit.ToolResult{Name: call.Name, Content: result}
}