Feat: tools

This commit is contained in:
Grail Finder
2025-08-27 10:03:09 +03:00
parent 975183d684
commit 57b808cb31
3 changed files with 107 additions and 2 deletions

65
tools.go Normal file
View File

@@ -0,0 +1,65 @@
package main
import (
"grailbench/models"
"time"
)
func sendEmail(args map[string]string) []byte {
logger.Info("send-email is used", "args", args)
return nil
}
func getCurrentTimestamp(args map[string]string) []byte {
ts := time.Now()
return []byte(ts.Format(time.RFC3339))
}
type fnSig func(map[string]string) []byte
var fnMap = map[string]fnSig{
"get_current_timestamp": getCurrentTimestamp,
"send_email": sendEmail,
}
// openai style def
var baseTools = []models.Tool{
// get_current_timestamp
models.Tool{
Type: "function",
Function: models.ToolFunc{
Name: "get_current_timestamp",
Description: "Returns current timestamp in RFC3999 format",
Parameters: models.ToolFuncParams{
Type: "object",
Required: []string{},
},
},
},
// send_email
models.Tool{
Type: "function",
Function: models.ToolFunc{
Name: "send_email",
Description: "Sends email to a provided address with given message.",
Parameters: models.ToolFuncParams{
Type: "object",
Required: []string{"address", "title", "body"},
Properties: map[string]models.ToolArgProps{
"address": models.ToolArgProps{
Type: "string",
Description: "email address of the recipient",
},
"title": models.ToolArgProps{
Type: "string",
Description: "",
},
"body": models.ToolArgProps{
Type: "string",
Description: "email body, can be in form of html page, markdown or pure text.",
},
},
},
},
},
}