Use Generative AI in Jupyter Notebook
You need access to at least one model provider. For more information on the available model providers, see the model providers documentation.
In Saagie, create the
$OPENAI_API_KEYenvironment variable at the project level. It must contain your API key for the model provider you want to use.
In your project, install the
JupyterLab+GenAI 4.0 Python 3.10app from the Saagie repository.
From your project’s Apps page, open your app by clicking Open on the corresponding card.
The Jupyter Notebook interface opens.
In your app, load the
jupyter_aiextension with the following command line:
Example 1. Request a Python program with ChatGPT
%%ai chatgpt Write a Python program that implements the quicksort algorithm in a function and uses it to sort a list of 100 random integers. Show the list before and after sorting.
For more information on supported language model providers, see Choosing a provider and model.