Primer
  • Factored Cognition Primer
  • Intro
    • Factored Cognition
    • Before We Start
  • Chapters
    • Hello World
    • Question Answering
      • Q&A without context
      • Q&A about short texts
    • Debate
      • Representing debates
      • From debates to prompts
      • The debate recipe
    • Long Texts
      • Loading paper text
      • Finding relevant paragraphs
      • Answering given paragraphs
    • Amplification
      • Asking subquestions
      • Answering subquestions
      • One-step amplification
      • Recursive amplification
    • Verifiers
      • Checking answers
      • Checking reasoning steps
    • Tool Use
      • Web search
      • Interpreters
    • Deduction
      • Chain of Thought
    • Action Selection
      • One-shot action selection
      • Iterative action selection
    • Amplification Revisited
  • Appendix
    • What’s next?
  • Links
    • We’re Hiring
    • Our Slack Community
    • ICE on Github
Powered by GitBook
On this page
Edit on GitHub
  1. Chapters

Hello World

The simplest recipe

PreviousBefore We StartNextQuestion Answering

Last updated 2 years ago

Let’s first get used to the infrastructure for writing, running, and debugging recipes.

Create a file hello.py anywhere:

hello.py
from ice.recipe import recipe


async def say_hello():
    return "Hello world!"


recipe.main(say_hello)

Run the recipe:

python hello.py

This will run the recipe and save an execution trace.

On the terminal, you will see a trace link and output:

Trace: http://localhost:8935/traces/01GE0GN5PPQWYGMT1B4GFPDZ09
Hello world!

If you follow the trace link (yours will be different), you will see a function node that you can click on, inspect inputs/outputs for, and show source code for:

The recipe, line by line
  • We use recipe.main to denote the recipe entry point and to automatically trace all global async functions that were defined in this file. Synchronous functions are assumed to be simple and fast, and not worth tracing.

  • recipe.main must appear at the bottom of the file.

  • The entry point must be async.

  • Most recipe functions will be async so that language model calls are parallelized as much as possible.

  • Different recipes take different arguments, which will be provided as keyword arguments to the entry point. This recipe doesn’t use any arguments.

Exercises

  1. Add another function and call it from say_hello. Does it show up in the trace? What if you make it async and call it as result = await my_function()?

Your first execution trace ()
view online