Tin

Examples · learn/20-teams · 243 of 339

critic

examples/learn/20-teams/critic.tintin run examples/learn/20-teams/critic.tin
type Review = {
  /// true when the draft is ready to publish
  ok: bool
  /// What to change, if anything
  advice: string
}

agent Writer { model: "mock", system: "Write and rewrite drafts." }
agent Critic { model: "mock", system: "Review drafts strictly." }

fn main() {
  var draft = Writer("a haiku about compilers")
  var round = 1
  loop {
    let r: Review = Critic("review this draft: {draft}")
    print("round {round}: ok={r.ok}")
    if r.ok || round == 3 { break }
    draft = Writer("rewrite it, staying true to this advice: {r.advice}")
    round += 1
  }
  print(draft)
}