MCPcopy
hub / github.com/wavetermdev/waveterm / GetAdderToolDefinition

Function GetAdderToolDefinition

pkg/aiusechat/tools.go:265–318  ·  view source on GitHub ↗

Used for internal testing of tool loops

()

Source from the content-addressed store, hash-verified

263
264// Used for internal testing of tool loops
265func GetAdderToolDefinition() uctypes.ToolDefinition {
266 return uctypes.ToolDefinition{
267 Name: "adder",
268 DisplayName: "Adder",
269 Description: "Add an array of numbers together and return their sum",
270 ToolLogName: "gen:adder",
271 Strict: true,
272 InputSchema: map[string]any{
273 "type": "object",
274 "properties": map[string]any{
275 "values": map[string]any{
276 "type": "array",
277 "items": map[string]any{
278 "type": "integer",
279 },
280 "description": "Array of numbers to add together",
281 },
282 },
283 "required": []string{"values"},
284 "additionalProperties": false,
285 },
286 ToolAnyCallback: func(input any, toolUseData *uctypes.UIMessageDataToolUse) (any, error) {
287 inputMap, ok := input.(map[string]any)
288 if !ok {
289 return nil, fmt.Errorf("invalid input format")
290 }
291
292 valuesInterface, ok := inputMap["values"]
293 if !ok {
294 return nil, fmt.Errorf("missing values parameter")
295 }
296
297 valuesSlice, ok := valuesInterface.([]any)
298 if !ok {
299 return nil, fmt.Errorf("values must be an array")
300 }
301
302 if len(valuesSlice) == 0 {
303 return 0, nil
304 }
305
306 sum := 0
307 for i, val := range valuesSlice {
308 floatVal, ok := val.(float64)
309 if !ok {
310 return nil, fmt.Errorf("value at index %d is not a number", i)
311 }
312 sum += int(floatVal)
313 }
314
315 return sum, nil
316 },
317 }
318}

Callers 4

makeOpenAIRequestFunction · 0.92
testT1Function · 0.92
testT2Function · 0.92
testT4Function · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected