Let’s start by making a recipe that returns subquestions given a question:
subquestions.py
from fvalues import Ffrom ice.recipe import recipedefmake_subquestion_prompt(question:str) ->str:returnF(f"""Decompose the following question into 2-5 subquestions that would help you answer the question. Make the questions stand alone, so that they can be answered without the context of the original question.Question: "{question}"Subquestions:-""" ).strip()asyncdefask_subquestions(question:str="What is the effect of creatine on cognition?",): prompt =make_subquestion_prompt(question) subquestions_text =await recipe.agent().complete(prompt=prompt) subquestions = [line.strip("- ")for line in subquestions_text.split("\n")]return subquestionsrecipe.main(ask_subquestions)
If we run this we get:
['What is creatine?','What is cognition?','How does creatine affect cognition?','What are the benefits of creatine on cognition?','What are the side effects of creatine on cognition?']