summaryrefslogtreecommitdiffhomepage
path: root/internal/llm/tools/tools.go
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-03-27 22:35:48 +0100
committerKujtim Hoxha <[email protected]>2025-04-01 13:38:54 +0200
commitafd9ad0560d76c2a6d161dad52553b10ff428905 (patch)
tree69f78b05ff0d7952cd3e3c9332f001e66abb2faf /internal/llm/tools/tools.go
parent904061c243f70696bfe781e97bf4e392e6954d07 (diff)
downloadopencode-afd9ad0560d76c2a6d161dad52553b10ff428905.tar.gz
opencode-afd9ad0560d76c2a6d161dad52553b10ff428905.zip
rework llm
Diffstat (limited to 'internal/llm/tools/tools.go')
-rw-r--r--internal/llm/tools/tools.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/llm/tools/tools.go b/internal/llm/tools/tools.go
new file mode 100644
index 000000000..e15c1c31f
--- /dev/null
+++ b/internal/llm/tools/tools.go
@@ -0,0 +1,49 @@
+package tools
+
+import "context"
+
+type ToolInfo struct {
+ Name string
+ Description string
+ Parameters map[string]any
+ Required []string
+}
+
+type toolResponseType string
+
+const (
+ ToolResponseTypeText toolResponseType = "text"
+ ToolResponseTypeImage toolResponseType = "image"
+)
+
+type ToolResponse struct {
+ Type toolResponseType `json:"type"`
+ Content string `json:"content"`
+ IsError bool `json:"is_error"`
+}
+
+func NewTextResponse(content string) ToolResponse {
+ return ToolResponse{
+ Type: ToolResponseTypeText,
+ Content: content,
+ }
+}
+
+func NewTextErrorResponse(content string) ToolResponse {
+ return ToolResponse{
+ Type: ToolResponseTypeText,
+ Content: content,
+ IsError: true,
+ }
+}
+
+type ToolCall struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Input string `json:"input"`
+}
+
+type BaseTool interface {
+ Info() ToolInfo
+ Run(ctx context.Context, params ToolCall) (ToolResponse, error)
+}