Tin

Examples · learn/28-browser · 293 of 339

shop

examples/learn/28-browser/shop.tintin run examples/learn/28-browser/shop.tin
/// Look up the price of an item, in cents.
tool fn price(item: string): int => if item == "tin cup" { 450 } else { 999 }

/// Charge the customer. A person approves every call.
guarded tool fn charge(cents: int): string => "charged {cents} cents"

agent Till {
  model: "mock"
  tools: [price, charge]
  on toolCall(name, input) => print("  {name} {input}")
}

fn main() {
  let name = input("your name: ")
  print("hello, {name}")
  print(Till("price 'tin cup'"))
  print(Till("charge 450"))
}