Tin

Examples · learn/17-typed-replies · 228 of 339

try

examples/learn/17-typed-replies/try.tintin run examples/learn/17-typed-replies/try.tin
/// Add two integers.
tool fn add(a: int, b: int): int => a + b

agent Hasty { model: "mock", tools: [add], maxTurns: 1 }   // only one model call allowed

fn main() {
  // A.try gives a Result instead of stopping the program when the call fails
  match Hasty.try("add 2 and 3") {
    Ok(text) => print(text)
    Err(e) => print("no answer: {e}")
  }
}