{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "bdede0af", "metadata": {}, "outputs": [], "source": [ "import ollama\n", "\n", "model = \"llama3\"\n", "messages = [\n", " {\"role\": \"user\", \"content\": \"Testing ollama type 5 random words\"}\n", "]\n", "\n", "response = ollama.chat(model=model, messages=messages)" ] }, { "cell_type": "code", "execution_count": 11, "id": "81b38610", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "A fun challenge!\n", "\n", "Here are 5 random words, type 5:\n", "\n", "1. Fjord\n", "2. Quiche\n", "3. Ninja\n", "4. Galaxy\n", "5. Pocket\n" ] } ], "source": [ "print(response[\"message\"][\"content\"])" ] }, { "cell_type": "code", "execution_count": 15, "id": "066f73af", "metadata": {}, "outputs": [], "source": [ "model2 = \"bk_test\"\n", "\n", "response2 = ollama.chat(model=model2, messages=messages)" ] }, { "cell_type": "code", "execution_count": 16, "id": "4a75aff1", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Arre yaar, lemme check dat out! *tapping on computer* Okay, here are 5 random words:\n", "\n", "1. **Mango**\n", "2. **Pyjamas**\n", "3. **Chai**\n", "4. **Bollywood**\n", "5. **Diwali**\n", "\n", "How's dat, yaar?\n" ] } ], "source": [ "print(response2[\"message\"][\"content\"])" ] }, { "cell_type": "code", "execution_count": 2, "id": "c8c310d8", "metadata": {}, "outputs": [], "source": [ "model_llava = \"llava\"\n", "messages_llava = [\n", " {\n", " \"role\": \"user\",\n", " \"content\": \"Explain the code in this image\",\n", " \"images\": [\n", " \"image4.png\"\n", " ]\n", " }\n", "]\n", "response_llava = ollama.chat(model=model_llava, messages=messages_llava)" ] }, { "cell_type": "code", "execution_count": 3, "id": "de949fdd", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " The image shows a computer screen with a Python script open in a text editor. The script appears to be a code snippet that is printing out a list of strings in a specific order. Here's the code:\n", "\n", "```python\n", "for i in range(len(my_list)):\n", " print(\"Word {} in {}\".format(i, my_list[i]))\n", "```\n", "\n", "This code is using a `for` loop to iterate through the elements of a list called `my_list`. The loop variable `i` is used to keep track of the current index in the loop. For each iteration, the code prints out a formatted string using the `print` function. The string format is `\"Word {} in {}\".format(i, my_list[i])`.\n", "\n", "The `format` method is used to replace placeholders in the string with the actual values. The placeholder `{}` is replaced with the value of `i` and the second placeholder `{}` is replaced with the value of `my_list[i]`. This results in the string `\"Word {} in {}\".format(i, my_list[i])` being replaced with `\"Word i in my_list[i]\"` for each iteration.\n", "\n", "The `range` function is used to generate a sequence of numbers from 0 to the length of `my_list - 1`. This allows the loop to iterate through all elements of the list.\n", "\n", "The output of the script would be a list of words, each word followed by its position within the list. The output would look something like this:\n", "\n", "```\n", "Word 0 in my_list[0]\n", "Word 1 in my_list[1]\n", "Word 2 in my_list[2]\n", "...\n", "Word n in my_list[n]\n", "```\n", "\n", "where `my_list` is the list being iterated over and `n` is the length of the list. \n" ] } ], "source": [ "print(response_llava[\"message\"][\"content\"])" ] } ], "metadata": { "kernelspec": { "display_name": "venv (3.13.5)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.5" } }, "nbformat": 4, "nbformat_minor": 5 }