Python and Ollama
In Part 1 you typed into a chat window. Here the same model answers calls from your Python code. Once the call is in a script, you can send a hundred records, keep every answer, and record exactly which model produced each one.
Notebook 01, 01_python_and_ollama, is planned for 20 minutes. In the session it gets about 18 minutes, from minute 10 to minute 28 of Part 2. It is a type-along: we run the cells together, and you change a few of them.
What the notebook covers
- List the models Ollama has and read a model’s facts from Python.
- Send a chat with a system prompt and control temperature, seed and context length.
- Stream an answer.
- Make the same call through the OpenAI client.
- Record provenance for every result.