2026-02-04 11:06:13 +00:00
|
|
|
package tools
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
|
|
type Tool interface {
|
|
|
|
|
Name() string
|
|
|
|
|
Description() string
|
|
|
|
|
Parameters() map[string]interface{}
|
2026-02-12 11:28:56 +00:00
|
|
|
Execute(ctx context.Context, args map[string]interface{}) *ToolResult
|
2026-02-04 11:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-11 04:28:37 +00:00
|
|
|
// ContextualTool is an optional interface that tools can implement
|
|
|
|
|
// to receive the current message context (channel, chatID)
|
|
|
|
|
type ContextualTool interface {
|
|
|
|
|
Tool
|
|
|
|
|
SetContext(channel, chatID string)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-04 11:06:13 +00:00
|
|
|
func ToolToSchema(tool Tool) map[string]interface{} {
|
|
|
|
|
return map[string]interface{}{
|
|
|
|
|
"type": "function",
|
|
|
|
|
"function": map[string]interface{}{
|
|
|
|
|
"name": tool.Name(),
|
|
|
|
|
"description": tool.Description(),
|
|
|
|
|
"parameters": tool.Parameters(),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|