Connect Riza’s Python code interpreter to Mistral
mistralai
and rizaio
packages with pip
:
code.py
file:
code.py
:
tools
and tool_choice
parameters in our initial request:
"auto"
is the default value for tool_choice
, and signals to the model that it can choose whether or not
to call a function. Setting this to "any"
will force the model to always call a function, which gives you a similar
level of control to the alternative direct prompting method described below.
code.py
after making all of the above additions:
exec_python
function with a valid Python script that
produces the required information for the model to provide a useful response.
Asking for something that doesn’t require code won’t trigger the function call:
code.py
:
response_format
parameter with the value {"type": "json_object"}
to enable JSON mode:
json
module to parse the model’s response:
exec()
or similar direct local execution.
code.py
after making all of the above additions: