66 lines
1.5 KiB
Go
66 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"grailbench/models"
|
|
"time"
|
|
)
|
|
|
|
func sendEmail(args map[string]string) []byte {
|
|
logger.Info("send-email is used", "args", args)
|
|
return []byte("email was sent")
|
|
}
|
|
|
|
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.",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|