Add Riza as a code interpreter to Google’s hosted Gemini model. Download and run the full example on GitHub.

import os
import rizaio
import google.generativeai as genai

# requires a valid Google Gemini API key in the GOOGLE_API_KEY env var
# requires a valid Riza API key in the RIZA_API_KEY env var

def execute_python(code:str):
    """ Executes a Python script and returns whatever was printed to stdout.

    The Python runtime does not have network or filesystem access,
    but does include the entire standard library. Read input from stdin and
    write output to stdout.
    riza = rizaio.Riza()
    resp = riza.command.exec(
    return resp.stdout

def main():
    model = genai.GenerativeModel('gemini-1.0-pro-latest', tools=[execute_python])
    chat = model.start_chat(enable_automatic_function_calling=True)
    response = chat.send_message('Please base64 encode the last message I sent')

    for content in chat.history:
        print(content.role, "->",
            [type(part).to_dict(part) for part in])

if __name__ == "__main__":