Comment on page

Asking subquestions

From question to more questions
Let’s start by making a recipe that returns subquestions given a question:
from fvalues import F
from ice.recipe import recipe
def make_subquestion_prompt(question: str) -> str:
return F(
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}"
async def ask_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 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?'
The trace:
Execution trace (view online)