← Questions
Multi-step task with an LLM tool-use loop
0
I was asked this
No reports yet. Sign in to say where you were asked it.
In a notebook with docs open, solve a multi-step problem by writing code that calls a language model as a building block: design the prompts and the loop that invokes tools and folds results back in. Starter API code is given; judgment about decomposition matters more than syntax.
class Tool:
def __init__(self, name, description, input_schema, fn): ...
def run_agent(client, model, system, user_message, tools, max_turns=8, max_tokens=1024):
"""Messages-API tool loop. Returns (final_text, messages)."""
def map_prompts(client, model, system, inputs, render, parse, workers=8, retries=1):
"""One validated call per input, in parallel."""
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
