Tin

Examples · learn/16-tools · 215 of 339

events

examples/learn/16-tools/events.tintin run examples/learn/16-tools/events.tin
/// Add two integers.
tool fn add(a: int, b: int): int => a + b

/// Multiply two integers.
tool fn times(a: int, b: int): int => a * b

agent Calculator {
  model: "mock"
  tools: [add, times]

  // handlers run while the agent loop runs
  on toolCall(name, input) => print("  call   {name} {input}")
  on toolResult(name, output, ok) => print("  result {name}: {output}")
}

fn main() {
  print(Calculator("times 6 and 7"))
}