react() async function, which drives a tool-use loop: the model
reasons about a goal, selects a tool, receives the result as an observation, and
repeats until it calls final_answer or the loop_budget is exhausted. Accepts
any list of AbstractMelleaTool instances and a ChatContext for multi-turn
history tracking. Raises RuntimeError if the loop ends without a final answer.
Functions
FUNC react
goal: the goal to be accomplished or the question to answercontext: the context being used; a type of ChatContextbackend: the backend used to generate the response.format: if set, the BaseModel to use for constrained decoding.model_options: additional model options, which will upsert into the model/backend’s defaults.tools: the list of tools to useloop_budget: the number of steps allowed; use -1 for unlimited
- A (ModelOutputThunk, Context) if
return_sampling_resultsisFalse, else returns aSamplingResult.
RuntimeError: if the loop ends before a final answer is found