mirror of
https://github.com/msgmate-io/open-chat-go-tool-interface.git
synced 2026-11-26 16:59:52 +00:00
An implementable tool interface that allows custom Tool compilation for open-code
- Go 100%
Expose the full JSON call-argument schema on the stable tool definition so compiled-in integrations can build model-callable tools without importing the core (backend/api/msgmate/tools). Mirrors the core ToolDefinition.InputSchema. Part of msgmate-io/open-chat-go-ci#423. |
||
|---|---|---|
| toolinterface | ||
| .gitignore | ||
| COPYRIGHT | ||
| go.mod | ||
| LICENSE | ||
| NOTICE | ||
| README.md | ||
go-tool-interface
Small Go SDK for registering external Open Chat tools.
This module remains independent and can be used by any Go project.
In Open Chat, tool definitions are discovered via integrations (go-integration-interface), not via a separate tooldeps.json manifest.
Migration for existing tool-only subrepos:
- Keep your tool definitions in this module.
- Add an integration package that imports those definitions.
- Register them via
integrationinterface.Definition{ToolDefinitions: ...}. - Add that integration module to
integrations.yaml.
Usage
package mytool
import "github.com/msgmate-io/go-tool-interface/toolinterface"
func init() {
toolinterface.MustRegister(toolinterface.Definition{
Name: "my_tool",
Description: "My external tool",
InputType: struct {
Message string `json:"message"`
}{},
RequiredParams: []string{"message"},
Parameters: map[string]interface{}{
"message": map[string]interface{}{"type": "string"},
},
Run: func(input interface{}, init map[string]interface{}) (string, error) {
in := input.(struct {
Message string `json:"message"`
})
return "echo: " + in.Message, nil
},
})
}
To expose tools in Open Chat, include the definitions in an integration's Definition.ToolDefinitions field.