Comment on page
The simplest recipe
Let’s first get used to the infrastructure for writing, running, and debugging recipes.
Create a file
from ice.recipe import recipe
async def say_hello():
return "Hello world!"
Run the recipe:
This will run the recipe and save an execution trace.
On the terminal, you will see a trace link and output:
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:
- We use
recipe.mainto 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.mainmust 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.
- 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()?