48 lines
874 B
Go
48 lines
874 B
Go
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSingleToolCall(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
tools := ToolsHandlers{
|
|
handlers: &map[string]ToolHandler{},
|
|
}
|
|
|
|
tools.AddTool("a", func(info ToolHandlerInfo, args string, call ToolCall) (any, error) {
|
|
return true, nil
|
|
})
|
|
|
|
response, err := tools.Handle(
|
|
ToolHandlerInfo{
|
|
UserId: uuid.Nil,
|
|
ImageId: uuid.Nil,
|
|
},
|
|
AgentAssistantToolCall{
|
|
Role: "assistant",
|
|
Content: "",
|
|
ToolCalls: []ToolCall{{
|
|
Index: 0,
|
|
Id: "1",
|
|
Function: FunctionCall{
|
|
Name: "a",
|
|
Arguments: "",
|
|
},
|
|
}},
|
|
})
|
|
|
|
if assert.NoError(err, "Tool call shouldnt return an error") {
|
|
assert.EqualValues(response, AgentTextMessage{
|
|
Role: "tool",
|
|
Content: "true",
|
|
ToolCallId: "1",
|
|
Name: "a",
|
|
})
|
|
}
|
|
}
|