Q&A without context

Answering questions without extra information

Let’s make our first recipe that calls out to an agent:

from fvalues import F

from ice.recipe import recipe

def make_qa_prompt(question: str) -> str:
    return F(
        f"""Answer the following question:

Question: "{question}"
Answer: "

async def answer(question: str = "What is happening on 9/9/2022?"):
    prompt = make_qa_prompt(question)
    answer = await recipe.agent().complete(prompt=prompt, stop='"')
    return answer


Wrapping f-strings in fvalues.F is entirely optional, but it makes traces a little bit nicer to work with.

Now let's try running this recipe:

python qa_simple.py

Looking at the trace, we see two nodes—one for the answer function we implemented, and one for the agent method call. If we click on the agent method, we see the exact prompt that was passed to the agent:

We can run recipes in different modes, which controls what type of agent is used. Some examples:

  • machine: Use an automated agent (usually GPT-3 if no hint is provided in the agent call). This is the default mode.

  • human: Elicit answers from you using a command-line interface.

  • augmented: Elicit answers from you, but providing the machine-generated answer as a default.

You specify the mode like this:

python qa_simple.py --mode human

Try running your recipe in different modes.

Because the agent’s answer method is async, we use await when we call it.

Last updated