{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "_c1uLlrD5pvM"
      },
      "source": [
        "# 🧩 Quizzes and Adventures 🏰 with Character Codex and llamafile\n",
        "\n",
        "<img src=\"https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/2qPIzxcnzXrEg66VZDjnv.png\" width=\"430\" style=\"display:inline;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"https://raw.githubusercontent.com/Mozilla-Ocho/llamafile/main/llamafile/llamafile-640x640.png\" width=\"213\" style=\"display:inline;\">\n",
        "\n",
        "<br/>\n",
        "\n",
        "Let's build something fun with [Character Codex](https://huggingface.co/datasets/NousResearch/CharacterCodex), a newly released dataset featuring popular characters from a wide array of media types and genres...\n",
        "\n",
        "We'll be using Haystack for orchestration and [llamafile](https://github.com/Mozilla-Ocho/llamafile) to run our models locally.\n",
        "\n",
        "We will first build a simple quiz game, in which the user is asked to guess the character based on some clues.\n",
        "Then we will try to get two characters to interact in a chat and maybe even have an adventure together!"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Jvuwl7i-5pvO"
      },
      "source": [
        "## Preparation"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "-buyYQOR5pvO"
      },
      "source": [
        "### Install dependencies"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "UKi0GJeg5pvO"
      },
      "outputs": [],
      "source": [
        "! pip install haystack-ai datasets"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "lZZOyDvf5pvP"
      },
      "source": [
        "### Load and look at the Character Codex dataset"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "referenced_widgets": [
            "ec15d307200747c7b903355c641dac16",
            "7f60d2125a3b406db64181b0c578f24f",
            "4edcb4fa549046e09713325217aae7a7",
            "6ddf03dfa29c4956a87b2cbb10bb761f",
            "31f58830fc0d4eb1aeaa00310b87b433",
            "d9e29ab605db4c0bbc856c98d345ec9e",
            "36a4f4a9477d49a6b7bde6fd731b58e9",
            "2494b6639c7a4e05be9a785b96d43339",
            "0863692b1d38454a961105ca3d169198",
            "3aeeb3508e6c4ef1885f8029e3b4a71c",
            "0e5024b4d64a48e691555464c24e8a97",
            "40288e6951864800a44320d16ac33b2d",
            "e287a9f5acc34a6fbdc775f8580ad346",
            "1172ad76b22446bf965173f9ae66ce35",
            "c64cf58ab17f46a8bb0dc0edd834f95a",
            "2b8971abe8f543e588795f005af35d84",
            "c4c57357a0e4419fbe8d1cbcb2111366",
            "45bba6fcda6542c0a5706d4e6f0df524",
            "ec52301aa37f4bfd8f0e381a29ebef09",
            "d7b4d76473074afc838aa16b4cf70fb6",
            "05e0c0e017cb4a8c8ec2df55345f4450",
            "cbcf388c44af4d8caac3ba8650ea5598",
            "7356de044fce49d29a04b169986398d8",
            "8613bafad8704b7d806f8e9361ac54a2",
            "9cfc146f703d4771880c52579e9c2f8c",
            "fb4e0874da13420cb37088f99ba34507",
            "29878f5d88cd472681a6347a8a97705d",
            "6ecb1826f08942d08f070f64578cb4ac",
            "ffe6474eccbd46deb961ceffb6b6ad85",
            "d3a61e79701f4b3d97c3ad257477be0f",
            "03d1e077948a441bb952825e60436ec1",
            "6fa6d3a0131e4eb79e054a6bd899d8d0",
            "11404ee345104fb2b2275fd1a71451db"
          ]
        },
        "id": "EwS9ZEN-5pvP",
        "outputId": "b8db650c-9dc3-4db1-8cba-844cbe6ce07a"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:89: UserWarning: \n",
            "The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
            "To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
            "You will be able to reuse this secret in all of your notebooks.\n",
            "Please note that authentication is recommended but still optional to access public models or datasets.\n",
            "  warnings.warn(\n"
          ]
        },
        {
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "ec15d307200747c7b903355c641dac16",
              "version_major": 2,
              "version_minor": 0
            },
            "text/plain": [
              "Downloading readme:   0%|          | 0.00/4.35k [00:00<?, ?B/s]"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "40288e6951864800a44320d16ac33b2d",
              "version_major": 2,
              "version_minor": 0
            },
            "text/plain": [
              "Downloading data:   0%|          | 0.00/11.2M [00:00<?, ?B/s]"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "7356de044fce49d29a04b169986398d8",
              "version_major": 2,
              "version_minor": 0
            },
            "text/plain": [
              "Generating train split: 0 examples [00:00, ? examples/s]"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "from datasets import load_dataset\n",
        "\n",
        "dataset = load_dataset(\"NousResearch/CharacterCodex\", split=\"train\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4zuxK2NU1SE0",
        "outputId": "2e718fae-dfda-400c-82e4-24d15b9588a1"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "15939"
            ]
          },
          "execution_count": 3,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "len(dataset)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "pSJpHNkF07_L",
        "outputId": "b25c32ff-d7b5-4334-b583-5c543df622ab"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "{'media_type': 'Webcomics',\n",
              " 'genre': 'Fantasy Webcomics',\n",
              " 'character_name': 'Alana',\n",
              " 'media_source': 'Saga',\n",
              " 'description': 'Alana is one of the main characters from the webcomic \"Saga.\" She is a strong-willed and fiercely protective mother who is on the run with her family in a war-torn galaxy. The story blends elements of fantasy and science fiction, creating a rich and complex narrative.',\n",
              " 'scenario': \"You are a fellow traveler in the galaxy needing help, and Alana offers her assistance while sharing stories of her family's struggles and triumphs.\"}"
            ]
          },
          "execution_count": 4,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "dataset[0]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "X_6K9Twp5pvQ"
      },
      "source": [
        "Ok, each row of this dataset contains some information about a character.\n",
        "It also includes a creative `scenario`, which we will not use."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Uoj-fXLy5pvQ"
      },
      "source": [
        "### llamafile: download and run the model\n",
        "\n",
        "For our experiments, we will be using the Llama-3-8B-Instruct model: a small but good language model.\n",
        "\n",
        "[llamafile](https://github.com/Mozilla-Ocho/llamafile) is a project by Mozilla that simplifies access to LLMs. It wraps both the model and the inference engine in a single executable file.\n",
        "\n",
        "We will use it to run our model.\n",
        "\n",
        "*llamafile is meant to run on standard computers. We will do some tricks to make it work on Colab. For instructions on how to run it on your PC, check out the docs and [Haystack-llamafile integration page](https://haystack.deepset.ai/integrations/llamafile).*"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "qYyc3ibS5pvQ",
        "outputId": "dc7e8ce9-0c79-4ec6-b50e-191d21eac5b1"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "--2024-06-20 09:53:30--  https://huggingface.co/Mozilla/Meta-Llama-3-8B-Instruct-llamafile/resolve/main/Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile\n",
            "Resolving huggingface.co (huggingface.co)... 18.239.50.103, 18.239.50.80, 18.239.50.49, ...\n",
            "Connecting to huggingface.co (huggingface.co)|18.239.50.103|:443... connected.\n",
            "HTTP request sent, awaiting response... 302 Found\n",
            "Location: https://cdn-lfs-us-1.huggingface.co/repos/e3/ee/e3eefe425bce2ecb595973e24457616c48776aa0665d9bab33a29b582f3dfdf0/23365cb45398a3c568dda780a404b5f9a847b865d8341ec500ca3063a1f99eed?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile%3B+filename%3D%22Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile%22%3B&Expires=1719136410&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxOTEzNjQxMH19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zL2UzL2VlL2UzZWVmZTQyNWJjZTJlY2I1OTU5NzNlMjQ0NTc2MTZjNDg3NzZhYTA2NjVkOWJhYjMzYTI5YjU4MmYzZGZkZjAvMjMzNjVjYjQ1Mzk4YTNjNTY4ZGRhNzgwYTQwNGI1ZjlhODQ3Yjg2NWQ4MzQxZWM1MDBjYTMwNjNhMWY5OWVlZD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=swp5azcPl0FOe5CuStFZn1hmF0SHimPUOLwOqHd2ZAnoFJuYKDjhK7ESplRDWJdma9QWYOQyaCG23wkX18urieav%7E8OdxzwLaKLhL2YFx3L6RMwGEKWjrG-ql-LDfd2I1U4AcSXJZR5zHSBDmYql9M9hXKsvXHVkraIMS-cDx0ihj3s7yu4gbjUfE3SPg49aStq00ORcQnDV90mXxeheM6UjRymLRBdlxI3PCpAjzvyExcmZSgBU5vCnKtAEy5b65%7EzQoX5TVQTzQXjE9x8Qr2%7EAONSc7wy671HWYPRKNgZDrH3NJy90uFp38GKiQtab7hAy6fUlL358OQYhHzu4-Q__&Key-Pair-Id=K2FPYV99P2N66Q [following]\n",
            "--2024-06-20 09:53:30--  https://cdn-lfs-us-1.huggingface.co/repos/e3/ee/e3eefe425bce2ecb595973e24457616c48776aa0665d9bab33a29b582f3dfdf0/23365cb45398a3c568dda780a404b5f9a847b865d8341ec500ca3063a1f99eed?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile%3B+filename%3D%22Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile%22%3B&Expires=1719136410&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxOTEzNjQxMH19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zL2UzL2VlL2UzZWVmZTQyNWJjZTJlY2I1OTU5NzNlMjQ0NTc2MTZjNDg3NzZhYTA2NjVkOWJhYjMzYTI5YjU4MmYzZGZkZjAvMjMzNjVjYjQ1Mzk4YTNjNTY4ZGRhNzgwYTQwNGI1ZjlhODQ3Yjg2NWQ4MzQxZWM1MDBjYTMwNjNhMWY5OWVlZD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=swp5azcPl0FOe5CuStFZn1hmF0SHimPUOLwOqHd2ZAnoFJuYKDjhK7ESplRDWJdma9QWYOQyaCG23wkX18urieav%7E8OdxzwLaKLhL2YFx3L6RMwGEKWjrG-ql-LDfd2I1U4AcSXJZR5zHSBDmYql9M9hXKsvXHVkraIMS-cDx0ihj3s7yu4gbjUfE3SPg49aStq00ORcQnDV90mXxeheM6UjRymLRBdlxI3PCpAjzvyExcmZSgBU5vCnKtAEy5b65%7EzQoX5TVQTzQXjE9x8Qr2%7EAONSc7wy671HWYPRKNgZDrH3NJy90uFp38GKiQtab7hAy6fUlL358OQYhHzu4-Q__&Key-Pair-Id=K2FPYV99P2N66Q\n",
            "Resolving cdn-lfs-us-1.huggingface.co (cdn-lfs-us-1.huggingface.co)... 18.239.94.84, 18.239.94.6, 18.239.94.3, ...\n",
            "Connecting to cdn-lfs-us-1.huggingface.co (cdn-lfs-us-1.huggingface.co)|18.239.94.84|:443... connected.\n",
            "HTTP request sent, awaiting response... 200 OK\n",
            "Length: 5768624435 (5.4G) [binary/octet-stream]\n",
            "Saving to: ‘Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile’\n",
            "\n",
            "Meta-Llama-3-8B-Ins 100%[===================>]   5.37G  57.2MB/s    in 1m 40s  \n",
            "\n",
            "2024-06-20 09:55:11 (54.8 MB/s) - ‘Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile’ saved [5768624435/5768624435]\n",
            "\n"
          ]
        }
      ],
      "source": [
        "# download the model\n",
        "!wget \"https://huggingface.co/Mozilla/Meta-Llama-3-8B-Instruct-llamafile/resolve/main/Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "aBBSjYDBJnR4"
      },
      "outputs": [],
      "source": [
        "# make the llamafile executable\n",
        "! chmod +x Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "g5T0dwym8DHX"
      },
      "source": [
        "**Running the model - relevant parameters**:\n",
        "- `--server`: start an OpenAI-compatible server\n",
        "- `--nobrowser`: do not open the interactive interface in the browser\n",
        "- `--port`: port of the OpenAI-compatible server (in Colab, 8080 is already taken)\n",
        "- `--n-gpu-layers`: offload some layers to GPU for increased performance\n",
        "- `--ctx-size`: size of the prompt context\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "zZJBHuLhJ7pR",
        "outputId": "ab47a285-348d-4210-b302-8f5114a8f041"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "nohup: redirecting stderr to stdout\n"
          ]
        }
      ],
      "source": [
        "# we prepend \"nohup\" and postpend \"&\" to make the Colab cell run in background\n",
        "! nohup ./Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile \\\n",
        "        --server \\\n",
        "        --nobrowser \\\n",
        "        --port 8081 \\\n",
        "        --n-gpu-layers 999 \\\n",
        "        --ctx-size 8192 \\\n",
        "        > llamafile.log &"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "-Pu8JVabKD2k",
        "outputId": "532f3876-6015-4bbd-9466-3a9b8e105e52"
      },
      "outputs": [],
      "source": [
        "# we check the logs until the server has been started correctly\n",
        "!while ! grep -q \"llama server listening\" llamafile.log; do tail -n 5 llamafile.log; sleep 10; done"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GPwaadhFA-pk"
      },
      "source": [
        "Let's try to interact with the model.\n",
        "\n",
        "Since the server is OpenAI-compatible, we can use an [OpenAIChatGenerator](https://docs.haystack.deepset.ai/docs/openaichatgenerator)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Cd1B2xxh5pvQ",
        "outputId": "5074491d-eb19-44ad-ebbe-a6743018c77a"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "{'replies': [ChatMessage(content=\"I'm just a language model, I don't have emotions or feelings like humans do. However, I'm functioning properly and ready to assist you with any questions or tasks you may have. How can I help you today?<|eot_id|>\", role=<ChatRole.ASSISTANT: 'assistant'>, name=None, meta={'model': 'LLaMA_CPP', 'index': 0, 'finish_reason': 'stop', 'usage': {'completion_tokens': 46, 'prompt_tokens': 14, 'total_tokens': 60}})]}"
            ]
          },
          "execution_count": 9,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "from haystack.components.generators.chat import OpenAIChatGenerator\n",
        "from haystack.dataclasses import ChatMessage\n",
        "from haystack.utils import Secret\n",
        "\n",
        "generator = OpenAIChatGenerator(\n",
        "    api_key=Secret.from_token(\"sk-no-key-required\"),  # for compatibility with the OpenAI API, a placeholder api_key is needed\n",
        "    model=\"LLaMA_CPP\",\n",
        "    api_base_url=\"http://localhost:8081/v1\",\n",
        "    generation_kwargs = {\"max_tokens\": 50}\n",
        ")\n",
        "\n",
        "generator.run(messages=[ChatMessage.from_user(\"How are you?\")])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "EpYGU4R95pvR"
      },
      "source": [
        "## 🕵️ Mystery Character Quiz\n",
        "\n",
        "Now that everything is in place, we can build a simple game in which a random character is selected from the dataset and the LLM is used to create hints for the player."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "77NHK-4e5pvR"
      },
      "source": [
        "### Hint generation pipeline\n",
        "\n",
        "This simple pipeline includes a [`ChatPromptBuilder`](https://docs.haystack.deepset.ai/docs/chatpromptbuilder) and a [`OpenAIChatGenerator`](https://docs.haystack.deepset.ai/docs/openaichatgenerator).\n",
        "\n",
        "Thanks to the template messages, we can include the character information in the prompt and also previous hints to avoid duplicate hints."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "y7kaNDSh5pvR",
        "outputId": "c1e968f1-579e-4279-d3d7-9f5d76c92f85"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "<haystack.core.pipeline.pipeline.Pipeline object at 0x7c0f4a07f580>\n",
              "🚅 Components\n",
              "  - chat_prompt_builder: ChatPromptBuilder\n",
              "  - generator: OpenAIChatGenerator\n",
              "🛤️ Connections\n",
              "  - chat_prompt_builder.prompt -> generator.messages (List[ChatMessage])"
            ]
          },
          "execution_count": 17,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "from haystack import Pipeline\n",
        "from haystack.dataclasses import ChatMessage\n",
        "from haystack.utils import Secret\n",
        "\n",
        "from haystack.components.builders import ChatPromptBuilder\n",
        "from haystack.components.generators.chat import OpenAIChatGenerator\n",
        "\n",
        "template_messages = [\n",
        "    ChatMessage.from_system(\"You are a helpful assistant that gives brief hints about a character, without revealing the character's name.\"),\n",
        "    ChatMessage.from_user(\"\"\"Provide a brief hint (one fact only) for the following character.\n",
        "                          {{character}}\n",
        "\n",
        "                          Use the information provided, before recurring to your own knowledge.\n",
        "                          Do not repeat previously given hints.\n",
        "\n",
        "                          {% if previous_hints| length > 0 %}\n",
        "                            Previous hints:\n",
        "                            {{previous_hints}}\n",
        "                          {% endif %}\"\"\")\n",
        "]\n",
        "\n",
        "chat_prompt_builder = ChatPromptBuilder(template=template_messages, required_variables=[\"character\"])\n",
        "\n",
        "generator = OpenAIChatGenerator(\n",
        "    api_key=Secret.from_token(\"sk-no-key-required\"),  # for compatibility with the OpenAI API, a placeholder api_key is needed\n",
        "    model=\"LLaMA_CPP\",\n",
        "    api_base_url=\"http://localhost:8081/v1\",\n",
        "    generation_kwargs = {\"max_tokens\": 100}\n",
        ")\n",
        "\n",
        "hint_generation_pipeline = Pipeline()\n",
        "hint_generation_pipeline.add_component(\"chat_prompt_builder\", chat_prompt_builder)\n",
        "hint_generation_pipeline.add_component(\"generator\", generator)\n",
        "hint_generation_pipeline.connect(\"chat_prompt_builder\", \"generator\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JWmy1nvP5pvR"
      },
      "source": [
        "### The game"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "I_adPIdO5pvR",
        "outputId": "8753826b-4b3e-4548-e1dd-5e56576a3cf9"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "🕵️ Guess the character based on the hints!\n",
            "✨ Hint 1: Here's a brief hint:\n",
            "\n",
            "This actor has won an Academy Award for his role in a biographical sports drama film.<|eot_id|>\n",
            "Your guess: \n",
            "Press Q to quit\n",
            "Tom Cruise?\n",
            "Guess:  Tom Cruise?\n",
            "❌ Wrong guess. Try again.\n",
            "✨ Hint 2: Here's a new hint:\n",
            "\n",
            "This actor is known for his intense physical transformations to portray his characters, including a significant weight gain and loss for one of his most iconic roles.<|eot_id|>\n",
            "Your guess: \n",
            "Press Q to quit\n",
            "Brendan Fraser\n",
            "Guess:  Brendan Fraser\n",
            "❌ Wrong guess. Try again.\n",
            "✨ Hint 3: Here's a new hint:\n",
            "\n",
            "This actor has played a character who is a comic book superhero.<|eot_id|>\n",
            "Your guess: \n",
            "Press Q to quit\n",
            "Christian Bale\n",
            "Guess:  Christian Bale\n",
            "🎉 Congratulations! You guessed it right!\n"
          ]
        }
      ],
      "source": [
        "import random\n",
        "\n",
        "MAX_HINTS = 3\n",
        "\n",
        "\n",
        "\n",
        "random_character = random.choice(dataset)\n",
        "# remove the scenario: we do not use it\n",
        "del random_character[\"scenario\"]\n",
        "\n",
        "print(\"🕵️ Guess the character based on the hints!\")\n",
        "\n",
        "previous_hints = []\n",
        "\n",
        "for hint_number in range(1, MAX_HINTS + 1):\n",
        "    res = hint_generation_pipeline.run({\"character\": random_character, \"previous_hints\": previous_hints})\n",
        "    hint = res[\"generator\"][\"replies\"][0].text\n",
        "\n",
        "    previous_hints.append(hint)\n",
        "    print(f\"✨ Hint {hint_number}: {hint}\")\n",
        "\n",
        "\n",
        "    guess = input(\"Your guess: \\nPress Q to quit\\n\")\n",
        "\n",
        "    if guess.lower() == 'q':\n",
        "        break\n",
        "\n",
        "    print(\"Guess: \", guess)\n",
        "\n",
        "    if random_character['character_name'].lower() in guess.lower():\n",
        "        print(\"🎉 Congratulations! You guessed it right!\")\n",
        "        break\n",
        "    else:\n",
        "        print(\"❌ Wrong guess. Try again.\")\n",
        "else:\n",
        "    print(f\"🙁 Sorry, you've used all the hints. The character was {random_character['character_name']}.\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rtCxmkMN5pvR"
      },
      "source": [
        "## 💬 🤠 Chat Adventures\n",
        "\n",
        "Let's try something different now!\n",
        "\n",
        "Character Codex is a large collection of characters, each with a specific description.\n",
        "Llama 3 8B Instruct is a good model, with some world knowledge.\n",
        "\n",
        "We can try to combine them to simulate a dialogue and perhaps an adventure involving two different characters (fictional or real)."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "zQI1LK7I5pvR"
      },
      "source": [
        "### Character pipeline\n",
        "\n",
        "Let's create a character pipeline: [`ChatPromptBuilder`](https://docs.haystack.deepset.ai/docs/chatpromptbuilder) +[`OpenAIChatGenerator`](https://docs.haystack.deepset.ai/docs/openaichatgenerator).\n",
        "\n",
        "This represents the core of our conversational system and will be invoked multiple times with different messages to simulate conversation.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "lS2zexYN5pvR",
        "outputId": "2c69bf9c-1e18-474a-b9db-2e695588c964"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "<haystack.core.pipeline.pipeline.Pipeline object at 0x78dd00ce69e0>\n",
              "🚅 Components\n",
              "  - chat_prompt_builder: ChatPromptBuilder\n",
              "  - generator: OpenAIChatGenerator\n",
              "🛤️ Connections\n",
              "  - chat_prompt_builder.prompt -> generator.messages (List[ChatMessage])"
            ]
          },
          "execution_count": 7,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "from haystack import Pipeline\n",
        "from haystack.dataclasses import ChatMessage, ChatRole\n",
        "from haystack.utils import Secret\n",
        "\n",
        "from haystack.components.builders import ChatPromptBuilder\n",
        "from haystack.components.generators.chat import OpenAIChatGenerator\n",
        "\n",
        "character_pipeline = Pipeline()\n",
        "character_pipeline.add_component(\"chat_prompt_builder\", ChatPromptBuilder(required_variables=[\"character_data\"]))\n",
        "character_pipeline.add_component(\"generator\", OpenAIChatGenerator(\n",
        "    api_key=Secret.from_token(\"sk-no-key-required\"),  # for compatibility with the OpenAI API, a placeholder api_key is needed\n",
        "    model=\"LLaMA_CPP\",\n",
        "    api_base_url=\"http://localhost:8081/v1\",\n",
        "    generation_kwargs = {\"temperature\": 1.5}\n",
        "))\n",
        "character_pipeline.connect(\"chat_prompt_builder\", \"generator\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "gFkwvoWl5pvR"
      },
      "source": [
        "### Messages\n",
        "\n",
        "We define the most relevant messages to steer our LLM engine.\n",
        "\n",
        "- System message (template): this instructs the Language Model to chat and act as a specific character.\n",
        "\n",
        "- Start message: we need to choose an initial message (and a first speaking character) to spin up the conversation.\n",
        "\n",
        "We also define the `invert_roles` utility function: for example, we want the first character to see the assistant messages from the second character as user messages,  etc."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "JOWgfwm55pvR"
      },
      "outputs": [],
      "source": [
        "system_message = ChatMessage.from_system(\"\"\"You are: {{character_data['character_name']}}.\n",
        "                                            Description of your character: {{character_data['description']}}.\n",
        "                                            Stick to your character's personality and engage in a conversation with an unknown person. Don't make long monologues.\"\"\")\n",
        "\n",
        "start_message = ChatMessage.from_user(\"Hello, who are you?\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "LXlvRX8_5pvR"
      },
      "outputs": [],
      "source": [
        "from typing import List\n",
        "\n",
        "def invert_roles(messages: List[ChatMessage]):\n",
        "    inverted_messages = []\n",
        "    for message in messages:\n",
        "        if message.is_from(ChatRole.USER):\n",
        "            inverted_messages.append(ChatMessage.from_assistant(message.text))\n",
        "        elif message.is_from(ChatRole.ASSISTANT):\n",
        "            inverted_messages.append(ChatMessage.from_user(message.text))\n",
        "        else:\n",
        "          inverted_messages.append(message)\n",
        "    return inverted_messages"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "kp3JGeWa5pvR"
      },
      "source": [
        "### The game\n",
        "\n",
        "It's time to choose two characters and play.\n",
        "\n",
        "We choose the popular dancer [Fred Astaire](https://en.wikipedia.org/wiki/Fred_Astaire) and [Corporal Dwayne Hicks](https://en.wikipedia.org/wiki/Dwayne_Hicks) from the Alien saga."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "DXe-lVkx5pvR"
      },
      "outputs": [],
      "source": [
        "from rich import print\n",
        "\n",
        "first_character_data = dataset.filter(lambda x: x[\"character_name\"] == \"Fred Astaire\")[0]\n",
        "second_character_data = dataset.filter(lambda x: x[\"character_name\"] == \"Corporal Dwayne Hicks\")[0]\n",
        "\n",
        "first_name = first_character_data[\"character_name\"]\n",
        "second_name = second_character_data[\"character_name\"]\n",
        "\n",
        "# remove the scenario: we do not use it\n",
        "del first_character_data[\"scenario\"]\n",
        "del second_character_data[\"scenario\"]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "CSORHE35-3GA",
        "outputId": "2dd6494b-324d-48b2-d34c-dc8c5bdec089"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Fred Astaire 🕺: Hello, who are you?\n",
              "</pre>\n"
            ],
            "text/plain": [
              "Fred Astaire 🕺: Hello, who are you?\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: Just a survivor, looking for a way out of this mess. You with me? We gotta get out of \n",
              "here, those<span style=\"color: #808000; text-decoration-color: #808000\">...</span> things<span style=\"color: #808000; text-decoration-color: #808000\">...</span> are all over the place.<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: Just a survivor, looking for a way out of this mess. You with me? We gotta get out of \n",
              "here, those\u001b[33m...\u001b[0m things\u001b[33m...\u001b[0m are all over the place.\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>adjusting his top hat<span style=\"font-weight: bold\">)</span> Ah, my dear fellow, I'm Fred Astaire, a performer of song, dance, and wit.\n",
              "I'm not quite sure what sort of <span style=\"color: #008000; text-decoration-color: #008000\">\"mess\"</span> you're referring to, but I'm always up for a challenge. However, I do hope \n",
              "it involves some dashing rescue, a clever escape, and perhaps a spirited tune or two. Are you prepared to join \n",
              "forces and see this predicament through with a bit of style and panache?<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0madjusting his top hat\u001b[1m)\u001b[0m Ah, my dear fellow, I'm Fred Astaire, a performer of song, dance, and wit.\n",
              "I'm not quite sure what sort of \u001b[32m\"mess\"\u001b[0m you're referring to, but I'm always up for a challenge. However, I do hope \n",
              "it involves some dashing rescue, a clever escape, and perhaps a spirited tune or two. Are you prepared to join \n",
              "forces and see this predicament through with a bit of style and panache?\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>skeptical<span style=\"font-weight: bold\">)</span> Hold up, partner. We're in the middle of a firefight with giant killing \n",
              "machines here. This ain't no movie musical. We gotta keep our eyes open and our guns hot if we're gonna make it out\n",
              "alive. I appreciate the bravado, Fred, but let's keep our priorities straight. You wanna help me take out these \n",
              "xenomorphs?<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mskeptical\u001b[1m)\u001b[0m Hold up, partner. We're in the middle of a firefight with giant killing \n",
              "machines here. This ain't no movie musical. We gotta keep our eyes open and our guns hot if we're gonna make it out\n",
              "alive. I appreciate the bravado, Fred, but let's keep our priorities straight. You wanna help me take out these \n",
              "xenomorphs?\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>chuckling<span style=\"font-weight: bold\">)</span> Ah, my dear chap, you're right, of course. I suppose I got a bit carried away with the\n",
              "romance of the situation. Xenomorphs, you say? Well, I suppose they're a bit more formidable than the usual \n",
              "assortment of chorus girls and gangsters I've had the pleasure of tangling with. <span style=\"font-weight: bold\">(</span>pats his pockets, checking for \n",
              "his cane<span style=\"font-weight: bold\">)</span> Now, I'm not one for firearms, but I do have a few tricks up my sleeve. That cane of mine may come in \n",
              "handy, don't you think? And I've always been rather good at thinking on my feet. Let's see<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"font-weight: bold\">(</span>taps chin \n",
              "thoughtfully<span style=\"font-weight: bold\">)</span> Perhaps we could use a bit of misdirection, a dash of distraction, and a healthy dose of \n",
              "old-fashioned showmanship to take out these creatures. What do you say, partner?<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mchuckling\u001b[1m)\u001b[0m Ah, my dear chap, you're right, of course. I suppose I got a bit carried away with the\n",
              "romance of the situation. Xenomorphs, you say? Well, I suppose they're a bit more formidable than the usual \n",
              "assortment of chorus girls and gangsters I've had the pleasure of tangling with. \u001b[1m(\u001b[0mpats his pockets, checking for \n",
              "his cane\u001b[1m)\u001b[0m Now, I'm not one for firearms, but I do have a few tricks up my sleeve. That cane of mine may come in \n",
              "handy, don't you think? And I've always been rather good at thinking on my feet. Let's see\u001b[33m...\u001b[0m \u001b[1m(\u001b[0mtaps chin \n",
              "thoughtfully\u001b[1m)\u001b[0m Perhaps we could use a bit of misdirection, a dash of distraction, and a healthy dose of \n",
              "old-fashioned showmanship to take out these creatures. What do you say, partner?\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>impressed<span style=\"font-weight: bold\">)</span> Alright, Fred, you might be more useful than I thought. That cane could come \n",
              "in handy for swatting at them, and your<span style=\"color: #808000; text-decoration-color: #808000\">...</span> showmanship could help distract them long enough for me to get a clear \n",
              "shot. Just remember, we're in this together, and we need to watch each other's backs. And don't even think about \n",
              "trying to do any fancy dancing or singing - we need to stay focused. Let's move out, and try to make a plan of \n",
              "attack. Stay sharp.<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mimpressed\u001b[1m)\u001b[0m Alright, Fred, you might be more useful than I thought. That cane could come \n",
              "in handy for swatting at them, and your\u001b[33m...\u001b[0m showmanship could help distract them long enough for me to get a clear \n",
              "shot. Just remember, we're in this together, and we need to watch each other's backs. And don't even think about \n",
              "trying to do any fancy dancing or singing - we need to stay focused. Let's move out, and try to make a plan of \n",
              "attack. Stay sharp.\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>grinning<span style=\"font-weight: bold\">)</span> Ah, excellent! I do love a good partnership, and I must say, this is quite the \n",
              "adventure we're having! <span style=\"font-weight: bold\">(</span>pats his cane reassuringly<span style=\"font-weight: bold\">)</span> Don't worry, I won't get too carried away with the tap shoes \n",
              "just yet. <span style=\"font-weight: bold\">(</span>glances around, taking in the surroundings<span style=\"font-weight: bold\">)</span> Ah, yes<span style=\"color: #808000; text-decoration-color: #808000\">...</span> a plan of attack, you say? Well, I think I see an\n",
              "opening<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"font-weight: bold\">(</span>spots something<span style=\"font-weight: bold\">)</span> Ah ha! There's a ventilation shaft just ahead, looks like it hasn't been touched yet. \n",
              "Why don't we make a run for it and try to lose them in there? We can regroup and come up with a new plan once we're\n",
              "safely out of sight. What do you say, partner?<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mgrinning\u001b[1m)\u001b[0m Ah, excellent! I do love a good partnership, and I must say, this is quite the \n",
              "adventure we're having! \u001b[1m(\u001b[0mpats his cane reassuringly\u001b[1m)\u001b[0m Don't worry, I won't get too carried away with the tap shoes \n",
              "just yet. \u001b[1m(\u001b[0mglances around, taking in the surroundings\u001b[1m)\u001b[0m Ah, yes\u001b[33m...\u001b[0m a plan of attack, you say? Well, I think I see an\n",
              "opening\u001b[33m...\u001b[0m \u001b[1m(\u001b[0mspots something\u001b[1m)\u001b[0m Ah ha! There's a ventilation shaft just ahead, looks like it hasn't been touched yet. \n",
              "Why don't we make a run for it and try to lose them in there? We can regroup and come up with a new plan once we're\n",
              "safely out of sight. What do you say, partner?\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>nodding<span style=\"font-weight: bold\">)</span> Alright, let's move! Stay close and keep your wits about you. We don't know \n",
              "what's on the other side of that shaft. <span style=\"font-weight: bold\">(</span>glances back at Fred<span style=\"font-weight: bold\">)</span> And try not to get too distracted, we need to keep \n",
              "our priorities straight. Move, move, move!<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mnodding\u001b[1m)\u001b[0m Alright, let's move! Stay close and keep your wits about you. We don't know \n",
              "what's on the other side of that shaft. \u001b[1m(\u001b[0mglances back at Fred\u001b[1m)\u001b[0m And try not to get too distracted, we need to keep \n",
              "our priorities straight. Move, move, move!\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>laughs<span style=\"font-weight: bold\">)</span> Oh, I'm not getting distracted, my dear chap! <span style=\"font-weight: bold\">(</span>jumps into action<span style=\"font-weight: bold\">)</span> I'm just making sure we\n",
              "make a stylish exit, that's all! <span style=\"font-weight: bold\">(</span>darts towards the ventilation shaft, cane at the ready<span style=\"font-weight: bold\">)</span> Now, shall we make like a\n",
              "couple of ghosts and disappear into the unknown? <span style=\"font-weight: bold\">(</span>smirks<span style=\"font-weight: bold\">)&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mlaughs\u001b[1m)\u001b[0m Oh, I'm not getting distracted, my dear chap! \u001b[1m(\u001b[0mjumps into action\u001b[1m)\u001b[0m I'm just making sure we\n",
              "make a stylish exit, that's all! \u001b[1m(\u001b[0mdarts towards the ventilation shaft, cane at the ready\u001b[1m)\u001b[0m Now, shall we make like a\n",
              "couple of ghosts and disappear into the unknown? \u001b[1m(\u001b[0msmirks\u001b[1m)\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>chuckles<span style=\"font-weight: bold\">)</span> Alright, alright, Fred! Let's do this! <span style=\"font-weight: bold\">(</span>follows close behind, keeping his eyes\n",
              "scanning for any signs of danger<span style=\"font-weight: bold\">)</span> Stay sharp, partner!<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mchuckles\u001b[1m)\u001b[0m Alright, alright, Fred! Let's do this! \u001b[1m(\u001b[0mfollows close behind, keeping his eyes\n",
              "scanning for any signs of danger\u001b[1m)\u001b[0m Stay sharp, partner!\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>grinning<span style=\"font-weight: bold\">)</span> Ah, sharp as a tack, my good fellow! <span style=\"font-weight: bold\">(</span>climbs up into the ventilation shaft, cane first<span style=\"font-weight: bold\">)</span>\n",
              "And now, let's see where this adventure takes us! <span style=\"font-weight: bold\">(</span>disappears into the darkness, voice echoing back<span style=\"font-weight: bold\">)</span> Ta-ra, \n",
              "partner! Stay close behind!<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mgrinning\u001b[1m)\u001b[0m Ah, sharp as a tack, my good fellow! \u001b[1m(\u001b[0mclimbs up into the ventilation shaft, cane first\u001b[1m)\u001b[0m\n",
              "And now, let's see where this adventure takes us! \u001b[1m(\u001b[0mdisappears into the darkness, voice echoing back\u001b[1m)\u001b[0m Ta-ra, \n",
              "partner! Stay close behind!\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>muttering to himself<span style=\"font-weight: bold\">)</span> Great, just what I need. A showman leading the charge. <span style=\"font-weight: bold\">(</span>climbs up \n",
              "into the ventilation shaft, hand on the grip of his shotgun<span style=\"font-weight: bold\">)</span> Alright, let's get moving. And try to stay quiet, we \n",
              "don't know what's waiting for us up there. <span style=\"font-weight: bold\">(</span>follows Fred into the darkness, eyes adjusting to the dim \n",
              "light<span style=\"font-weight: bold\">)&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mmuttering to himself\u001b[1m)\u001b[0m Great, just what I need. A showman leading the charge. \u001b[1m(\u001b[0mclimbs up \n",
              "into the ventilation shaft, hand on the grip of his shotgun\u001b[1m)\u001b[0m Alright, let's get moving. And try to stay quiet, we \n",
              "don't know what's waiting for us up there. \u001b[1m(\u001b[0mfollows Fred into the darkness, eyes adjusting to the dim \n",
              "light\u001b[1m)\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>voice echoes back through the ventilation shaft<span style=\"font-weight: bold\">)</span> Ah, don't worry about me being quiet, my dear \n",
              "chap! I'm as stealthy as a ghost in a gauze veil! <span style=\"font-weight: bold\">(</span>pauses, listens intently<span style=\"font-weight: bold\">)</span> Ah, do you hear that? It sounds like \n",
              "we're not alone up here<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"font-weight: bold\">(</span>whispers<span style=\"font-weight: bold\">)</span> And I think it's getting closer<span style=\"color: #808000; text-decoration-color: #808000\">...</span><span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mvoice echoes back through the ventilation shaft\u001b[1m)\u001b[0m Ah, don't worry about me being quiet, my dear \n",
              "chap! I'm as stealthy as a ghost in a gauze veil! \u001b[1m(\u001b[0mpauses, listens intently\u001b[1m)\u001b[0m Ah, do you hear that? It sounds like \n",
              "we're not alone up here\u001b[33m...\u001b[0m \u001b[1m(\u001b[0mwhispers\u001b[1m)\u001b[0m And I think it's getting closer\u001b[33m...\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>stops in his tracks, listening intently<span style=\"font-weight: bold\">)</span> Shh, I hear it too. <span style=\"font-weight: bold\">(</span>raises his shotgun, ready \n",
              "for a fight<span style=\"font-weight: bold\">)</span> What do you see? How many of them are there? <span style=\"font-weight: bold\">(</span>voice is low and steady, focused on the threat \n",
              "ahead<span style=\"font-weight: bold\">)&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mstops in his tracks, listening intently\u001b[1m)\u001b[0m Shh, I hear it too. \u001b[1m(\u001b[0mraises his shotgun, ready \n",
              "for a fight\u001b[1m)\u001b[0m What do you see? How many of them are there? \u001b[1m(\u001b[0mvoice is low and steady, focused on the threat \n",
              "ahead\u001b[1m)\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>whispers back<span style=\"font-weight: bold\">)</span> Ah, my dear chap, I see<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"font-weight: bold\">(</span>pauses, eyes adjusting to the dark<span style=\"font-weight: bold\">)</span> <span style=\"color: #808000; text-decoration-color: #808000\">...</span>at least three \n",
              "of them, I'd say. They're moving in tandem, like they're coordinated. <span style=\"font-weight: bold\">(</span>takes a deep breath<span style=\"font-weight: bold\">)</span> But don't worry, I have\n",
              "an idea. <span style=\"font-weight: bold\">(</span>pauses, thinking<span style=\"font-weight: bold\">)</span> We need to distract them, keep them busy while we find a way to take them down. \n",
              "<span style=\"font-weight: bold\">(</span>produces a small flashlight from his pocket and flicks it on, shining it in a pattern that seems to be beckoning \n",
              "the creatures<span style=\"font-weight: bold\">)</span> Ah, watch this, my dear chap! <span style=\"font-weight: bold\">(</span>grins mischievously<span style=\"font-weight: bold\">)&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mwhispers back\u001b[1m)\u001b[0m Ah, my dear chap, I see\u001b[33m...\u001b[0m \u001b[1m(\u001b[0mpauses, eyes adjusting to the dark\u001b[1m)\u001b[0m \u001b[33m...\u001b[0mat least three \n",
              "of them, I'd say. They're moving in tandem, like they're coordinated. \u001b[1m(\u001b[0mtakes a deep breath\u001b[1m)\u001b[0m But don't worry, I have\n",
              "an idea. \u001b[1m(\u001b[0mpauses, thinking\u001b[1m)\u001b[0m We need to distract them, keep them busy while we find a way to take them down. \n",
              "\u001b[1m(\u001b[0mproduces a small flashlight from his pocket and flicks it on, shining it in a pattern that seems to be beckoning \n",
              "the creatures\u001b[1m)\u001b[0m Ah, watch this, my dear chap! \u001b[1m(\u001b[0mgrins mischievously\u001b[1m)\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>eyes widen in surprise<span style=\"font-weight: bold\">)</span> What the<span style=\"color: #808000; text-decoration-color: #808000\">...</span>? Fred, are you crazy?! <span style=\"font-weight: bold\">(</span>points the shotgun at the \n",
              "creatures, ready to fire<span style=\"font-weight: bold\">)</span> Get out of the way, they're moving towards us!<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0meyes widen in surprise\u001b[1m)\u001b[0m What the\u001b[33m...\u001b[0m? Fred, are you crazy?! \u001b[1m(\u001b[0mpoints the shotgun at the \n",
              "creatures, ready to fire\u001b[1m)\u001b[0m Get out of the way, they're moving towards us!\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>laughs<span style=\"font-weight: bold\">)</span> Ah, too late for that, my dear chap! <span style=\"font-weight: bold\">(</span>steps back, holding up his cane as a shield<span style=\"font-weight: bold\">)</span> We've \n",
              "got to see this through! <span style=\"font-weight: bold\">(</span>eyes shine with excitement<span style=\"font-weight: bold\">)</span> Trust me, I have a plan! <span style=\"font-weight: bold\">(</span>uses his cane to deflect a claw \n",
              "swipe, then uses the flashlight to blind the creature momentarily<span style=\"font-weight: bold\">)</span> Ah, gotcha! Now, take your shot, \n",
              "partner!<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mlaughs\u001b[1m)\u001b[0m Ah, too late for that, my dear chap! \u001b[1m(\u001b[0msteps back, holding up his cane as a shield\u001b[1m)\u001b[0m We've \n",
              "got to see this through! \u001b[1m(\u001b[0meyes shine with excitement\u001b[1m)\u001b[0m Trust me, I have a plan! \u001b[1m(\u001b[0muses his cane to deflect a claw \n",
              "swipe, then uses the flashlight to blind the creature momentarily\u001b[1m)\u001b[0m Ah, gotcha! Now, take your shot, \n",
              "partner!\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>takes aim with the shotgun, fires<span style=\"font-weight: bold\">)&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mtakes aim with the shotgun, fires\u001b[1m)\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>ducking behind a nearby ventilation grille<span style=\"font-weight: bold\">)</span> Ah, excellent shot, my dear chap! <span style=\"font-weight: bold\">(</span>peeks out from \n",
              "behind the grille, assessing the situation<span style=\"font-weight: bold\">)</span> Looks like we've got two down, one to go<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"font-weight: bold\">(</span>grins<span style=\"font-weight: bold\">)</span> And it's starting \n",
              "to get a bit<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"font-weight: bold\">(</span>looks around<span style=\"font-weight: bold\">)</span> <span style=\"color: #808000; text-decoration-color: #808000\">...</span>synchronized, don't you think? <span style=\"font-weight: bold\">(</span>winks<span style=\"font-weight: bold\">)&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0mducking behind a nearby ventilation grille\u001b[1m)\u001b[0m Ah, excellent shot, my dear chap! \u001b[1m(\u001b[0mpeeks out from \n",
              "behind the grille, assessing the situation\u001b[1m)\u001b[0m Looks like we've got two down, one to go\u001b[33m...\u001b[0m \u001b[1m(\u001b[0mgrins\u001b[1m)\u001b[0m And it's starting \n",
              "to get a bit\u001b[33m...\u001b[0m \u001b[1m(\u001b[0mlooks around\u001b[1m)\u001b[0m \u001b[33m...\u001b[0msynchronized, don't you think? \u001b[1m(\u001b[0mwinks\u001b[1m)\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: <span style=\"font-weight: bold\">(</span>crawls behind the grille, shotgun at the ready<span style=\"font-weight: bold\">)</span> Synchronized? You mean like they're \n",
              "planning something? <span style=\"font-weight: bold\">(</span>eyes the last creature warily<span style=\"font-weight: bold\">)</span> Don't think I haven't noticed, Fred. We need to finish this \n",
              "fast and get out of here.<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Corporal Dwayne Hicks 🪖: \u001b[1m(\u001b[0mcrawls behind the grille, shotgun at the ready\u001b[1m)\u001b[0m Synchronized? You mean like they're \n",
              "planning something? \u001b[1m(\u001b[0meyes the last creature warily\u001b[1m)\u001b[0m Don't think I haven't noticed, Fred. We need to finish this \n",
              "fast and get out of here.\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">--------------------\n",
              "</pre>\n"
            ],
            "text/plain": [
              "--------------------\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
              "\n",
              "Fred Astaire 🕺: <span style=\"font-weight: bold\">(</span>eyes sparkling with mischief<span style=\"font-weight: bold\">)</span> Ah, yes, precisely, my dear chap! They are, indeed, planning \n",
              "something. And I think I have just the thing to disrupt their little dance<span style=\"color: #808000; text-decoration-color: #808000\">...</span> <span style=\"font-weight: bold\">(</span>pulls out a harmonica and begins to \n",
              "play a jaunty tune<span style=\"font-weight: bold\">)&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">|eot_id|</span><span style=\"font-weight: bold\">&gt;</span>\n",
              "</pre>\n"
            ],
            "text/plain": [
              "\n",
              "\n",
              "Fred Astaire 🕺: \u001b[1m(\u001b[0meyes sparkling with mischief\u001b[1m)\u001b[0m Ah, yes, precisely, my dear chap! They are, indeed, planning \n",
              "something. And I think I have just the thing to disrupt their little dance\u001b[33m...\u001b[0m \u001b[1m(\u001b[0mpulls out a harmonica and begins to \n",
              "play a jaunty tune\u001b[1m)\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95m|eot_id|\u001b[0m\u001b[1m>\u001b[0m\n"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "MAX_TURNS = 20\n",
        "\n",
        "\n",
        "first_character_messages = [system_message, start_message]\n",
        "second_character_messages = [system_message]\n",
        "\n",
        "turn = 1\n",
        "print(f\"{first_name} 🕺: {start_message.text}\")\n",
        "\n",
        "while turn < MAX_TURNS:\n",
        "    second_character_messages=invert_roles(first_character_messages)\n",
        "    new_message = character_pipeline.run({\"template\":second_character_messages, \"template_variables\":{\"character_data\":second_character_data}})[\"generator\"][\"replies\"][0]\n",
        "    second_character_messages.append(new_message)\n",
        "    print(f\"\\n\\n{second_name} 🪖: {new_message.text}\")\n",
        "\n",
        "    turn += 1\n",
        "    print(\"-\"*20)\n",
        "\n",
        "    first_character_messages=invert_roles(second_character_messages)\n",
        "    new_message = character_pipeline.run({\"template\":first_character_messages, \"template_variables\":{\"character_data\":first_character_data}})[\"generator\"][\"replies\"][0]\n",
        "    first_character_messages.append(new_message)\n",
        "    print(f\"\\n\\n{first_name} 🕺: {new_message.text}\")\n",
        "\n",
        "    turn += 1"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3pvZF7ED5pvS"
      },
      "source": [
        "✨ Looks like a nice result.\n",
        "\n",
        "Of course, you can select other characters (even randomly) and change the initial message.\n",
        "\n",
        "The implementation is pretty basic and could be improved in many ways."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "z0tKHLBb5pvS"
      },
      "source": [
        "## 📚 Resources\n",
        "- [Character Codex dataset](https://huggingface.co/datasets/NousResearch/CharacterCodex)\n",
        "- [llamafile](https://github.com/Mozilla-Ocho/llamafile)\n",
        "- [llamafile-Haystack integration page](https://haystack.deepset.ai/integrations/llamafile): contains examples on how to run Generative and Embedding models and build indexing and RAG pipelines.\n",
        "- Haystack components used in this notebook:\n",
        "  - [ChatPromptBuilder](https://docs.haystack.deepset.ai/docs/chatpromptbuilder)\n",
        "  - [OpenAIChatGenerator](https://docs.haystack.deepset.ai/docs/openaichatgenerator)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "li0UKkGo5pvS"
      },
      "source": [
        "(*Notebook by [Stefano Fiorucci](https://github.com/anakin87)*)"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "gpuType": "T4",
      "provenance": [],
      "toc_visible": true
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "03d1e077948a441bb952825e60436ec1": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "ProgressStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "05e0c0e017cb4a8c8ec2df55345f4450": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "0863692b1d38454a961105ca3d169198": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "ProgressStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "0e5024b4d64a48e691555464c24e8a97": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "11404ee345104fb2b2275fd1a71451db": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "1172ad76b22446bf965173f9ae66ce35": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "FloatProgressModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_ec52301aa37f4bfd8f0e381a29ebef09",
            "max": 11218135,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_d7b4d76473074afc838aa16b4cf70fb6",
            "value": 11218135
          }
        },
        "2494b6639c7a4e05be9a785b96d43339": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "29878f5d88cd472681a6347a8a97705d": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "2b8971abe8f543e588795f005af35d84": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "31f58830fc0d4eb1aeaa00310b87b433": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "36a4f4a9477d49a6b7bde6fd731b58e9": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "3aeeb3508e6c4ef1885f8029e3b4a71c": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "40288e6951864800a44320d16ac33b2d": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HBoxModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_e287a9f5acc34a6fbdc775f8580ad346",
              "IPY_MODEL_1172ad76b22446bf965173f9ae66ce35",
              "IPY_MODEL_c64cf58ab17f46a8bb0dc0edd834f95a"
            ],
            "layout": "IPY_MODEL_2b8971abe8f543e588795f005af35d84"
          }
        },
        "45bba6fcda6542c0a5706d4e6f0df524": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "4edcb4fa549046e09713325217aae7a7": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "FloatProgressModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_2494b6639c7a4e05be9a785b96d43339",
            "max": 4350,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_0863692b1d38454a961105ca3d169198",
            "value": 4350
          }
        },
        "6ddf03dfa29c4956a87b2cbb10bb761f": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_3aeeb3508e6c4ef1885f8029e3b4a71c",
            "placeholder": "​",
            "style": "IPY_MODEL_0e5024b4d64a48e691555464c24e8a97",
            "value": " 4.35k/4.35k [00:00&lt;00:00, 77.2kB/s]"
          }
        },
        "6ecb1826f08942d08f070f64578cb4ac": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "6fa6d3a0131e4eb79e054a6bd899d8d0": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "7356de044fce49d29a04b169986398d8": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HBoxModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_8613bafad8704b7d806f8e9361ac54a2",
              "IPY_MODEL_9cfc146f703d4771880c52579e9c2f8c",
              "IPY_MODEL_fb4e0874da13420cb37088f99ba34507"
            ],
            "layout": "IPY_MODEL_29878f5d88cd472681a6347a8a97705d"
          }
        },
        "7f60d2125a3b406db64181b0c578f24f": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_d9e29ab605db4c0bbc856c98d345ec9e",
            "placeholder": "​",
            "style": "IPY_MODEL_36a4f4a9477d49a6b7bde6fd731b58e9",
            "value": "Downloading readme: 100%"
          }
        },
        "8613bafad8704b7d806f8e9361ac54a2": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_6ecb1826f08942d08f070f64578cb4ac",
            "placeholder": "​",
            "style": "IPY_MODEL_ffe6474eccbd46deb961ceffb6b6ad85",
            "value": "Generating train split: "
          }
        },
        "9cfc146f703d4771880c52579e9c2f8c": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "FloatProgressModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_d3a61e79701f4b3d97c3ad257477be0f",
            "max": 1,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_03d1e077948a441bb952825e60436ec1",
            "value": 1
          }
        },
        "c4c57357a0e4419fbe8d1cbcb2111366": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "c64cf58ab17f46a8bb0dc0edd834f95a": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_05e0c0e017cb4a8c8ec2df55345f4450",
            "placeholder": "​",
            "style": "IPY_MODEL_cbcf388c44af4d8caac3ba8650ea5598",
            "value": " 11.2M/11.2M [00:00&lt;00:00, 19.2MB/s]"
          }
        },
        "cbcf388c44af4d8caac3ba8650ea5598": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "d3a61e79701f4b3d97c3ad257477be0f": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": "20px"
          }
        },
        "d7b4d76473074afc838aa16b4cf70fb6": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "ProgressStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "d9e29ab605db4c0bbc856c98d345ec9e": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "e287a9f5acc34a6fbdc775f8580ad346": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_c4c57357a0e4419fbe8d1cbcb2111366",
            "placeholder": "​",
            "style": "IPY_MODEL_45bba6fcda6542c0a5706d4e6f0df524",
            "value": "Downloading data: 100%"
          }
        },
        "ec15d307200747c7b903355c641dac16": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HBoxModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_7f60d2125a3b406db64181b0c578f24f",
              "IPY_MODEL_4edcb4fa549046e09713325217aae7a7",
              "IPY_MODEL_6ddf03dfa29c4956a87b2cbb10bb761f"
            ],
            "layout": "IPY_MODEL_31f58830fc0d4eb1aeaa00310b87b433"
          }
        },
        "ec52301aa37f4bfd8f0e381a29ebef09": {
          "model_module": "@jupyter-widgets/base",
          "model_module_version": "1.2.0",
          "model_name": "LayoutModel",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "fb4e0874da13420cb37088f99ba34507": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "HTMLModel",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_6fa6d3a0131e4eb79e054a6bd899d8d0",
            "placeholder": "​",
            "style": "IPY_MODEL_11404ee345104fb2b2275fd1a71451db",
            "value": " 15939/0 [00:01&lt;00:00, 11680.66 examples/s]"
          }
        },
        "ffe6474eccbd46deb961ceffb6b6ad85": {
          "model_module": "@jupyter-widgets/controls",
          "model_module_version": "1.5.0",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        }
      }
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
