Add core implementation for AI-powered question answering
Introduce multiple agents, tools, and utilities for processing, extracting, and answering user-provided questions using LLMs and external data. Key features include knowledge processing, question splitting, search term generation, and contextual knowledge handling.
This commit is contained in:
27
pkg/agents/tools/calculator.go
Normal file
27
pkg/agents/tools/calculator.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"go.starlark.net/lib/math"
|
||||
"go.starlark.net/starlark"
|
||||
"go.starlark.net/syntax"
|
||||
|
||||
gollm "gitea.stevedudenhoeffer.com/steve/go-llm"
|
||||
)
|
||||
|
||||
var Calculator = gollm.NewFunction(
|
||||
"calculator",
|
||||
"A starlark calculator",
|
||||
func(ctx *gollm.Context, args struct {
|
||||
Expression string `description:"The expression to evaluate using starlark"`
|
||||
}) (string, error) {
|
||||
val, err := starlark.EvalOptions(&syntax.FileOptions{},
|
||||
&starlark.Thread{Name: "main"},
|
||||
"input",
|
||||
args.Expression,
|
||||
math.Module.Members)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return val.String(), nil
|
||||
})
|
Reference in New Issue
Block a user