add: more commands
This commit is contained in:
@@ -4,9 +4,16 @@ package tools
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/ollama/ollama/api"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/rcon"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/give"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/say"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/teleport"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/time"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/weather"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/zombie"
|
||||
)
|
||||
|
||||
type Tool interface {
|
||||
@@ -25,6 +32,18 @@ func New(tools ...Tool) Tools {
|
||||
return ret
|
||||
}
|
||||
|
||||
// DefaultTools returns the default set of tools for mc-god
|
||||
func DefaultTools() Tools {
|
||||
return New(
|
||||
say.Get(),
|
||||
teleport.Get(),
|
||||
give.Get(),
|
||||
weather.Get(),
|
||||
time.Get(),
|
||||
zombie.Get(),
|
||||
)
|
||||
}
|
||||
|
||||
func (t Tools) AsAPI() api.Tools {
|
||||
var ret api.Tools
|
||||
for _, tool := range t {
|
||||
@@ -38,5 +57,10 @@ func (t Tools) Do(ctx context.Context, toolCall api.ToolCall, client *rcon.Clien
|
||||
if !found {
|
||||
return fmt.Errorf("unknown tool %q", toolCall.Function.Name)
|
||||
}
|
||||
args, err := toolCall.Function.Arguments.MarshalJSON()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal args: %v", err)
|
||||
}
|
||||
slog.Info("calling function", "name", toolCall.Function.Name, "args", string(args))
|
||||
return tool.Do(ctx, toolCall, client)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user