implement nested tool calls and initial setup for result metadata

This commit is contained in:
Kujtim Hoxha
2025-04-12 14:49:01 +02:00
parent 8d874b839d
commit 0697dcc1d9
14 changed files with 585 additions and 168 deletions

View File

@@ -1,6 +1,9 @@
package tools
import "context"
import (
"context"
"encoding/json"
)
type ToolInfo struct {
Name string
@@ -17,9 +20,10 @@ const (
)
type ToolResponse struct {
Type toolResponseType `json:"type"`
Content string `json:"content"`
IsError bool `json:"is_error"`
Type toolResponseType `json:"type"`
Content string `json:"content"`
Metadata string `json:"metadata,omitempty"`
IsError bool `json:"is_error"`
}
func NewTextResponse(content string) ToolResponse {
@@ -29,6 +33,17 @@ func NewTextResponse(content string) ToolResponse {
}
}
func WithResponseMetadata(response ToolResponse, metadata any) ToolResponse {
if metadata != nil {
metadataBytes, err := json.Marshal(metadata)
if err != nil {
return response
}
response.Metadata = string(metadataBytes)
}
return response
}
func NewTextErrorResponse(content string) ToolResponse {
return ToolResponse{
Type: ToolResponseTypeText,