{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Movie Recommendation System Using OpenAGI\n",
        "\n",
        "This notebook leverages the OpenAGI framework to create an interactive movie recommendation system.\n"
      ],
      "metadata": {
        "id": "IoJG4MxjpcJP"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Installation\n",
        "\n",
        "Before running the script, ensure you have the OpenAGI library installed. You can install it using the following command:"
      ],
      "metadata": {
        "id": "exvpBvE1pf0b"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "collapsed": true,
        "id": "LIo2gWD7etPf",
        "outputId": "05aeb2f9-d91c-497d-ce41-237c64a08c04"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Requirement already satisfied: openagi in /usr/local/lib/python3.10/dist-packages (0.2.9.5)\n",
            "Requirement already satisfied: azure-identity<2.0.0,>=1.15.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (1.17.1)\n",
            "Requirement already satisfied: chromadb<0.6.0,>=0.5.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.5.5)\n",
            "Requirement already satisfied: duckduckgo-search<7.0.0,>=6.1.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (6.2.10)\n",
            "Requirement already satisfied: faiss-cpu<2.0.0,>=1.8.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (1.8.0.post1)\n",
            "Requirement already satisfied: fake-useragent<2.0.0,>=1.5.1 in /usr/local/lib/python3.10/dist-packages (from openagi) (1.5.1)\n",
            "Requirement already satisfied: fastapi<0.111.0,>=0.110.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.110.3)\n",
            "Requirement already satisfied: google-api-python-client<3.0.0,>=2.121.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (2.137.0)\n",
            "Requirement already satisfied: google-auth-httplib2<0.3.0,>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.2.0)\n",
            "Requirement already satisfied: google-auth-oauthlib<2.0.0,>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (1.2.1)\n",
            "Requirement already satisfied: google-search-results<3.0.0,>=2.4.2 in /usr/local/lib/python3.10/dist-packages (from openagi) (2.4.2)\n",
            "Requirement already satisfied: langchain==0.1.8 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.1.8)\n",
            "Requirement already satisfied: langchain-community==0.0.21 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.0.21)\n",
            "Requirement already satisfied: langchain-exa<0.0.2,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.0.1)\n",
            "Requirement already satisfied: langchain-experimental<0.0.54,>=0.0.53 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.0.53)\n",
            "Requirement already satisfied: langchain-openai==0.0.6 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.0.6)\n",
            "Requirement already satisfied: langchain-text-splitters<0.0.2,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.0.1)\n",
            "Requirement already satisfied: langchainhub<0.2.0,>=0.1.15 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.1.21)\n",
            "Requirement already satisfied: numpy<2.0.0,>=1.26.4 in /usr/local/lib/python3.10/dist-packages (from openagi) (1.26.4)\n",
            "Requirement already satisfied: ollama<0.2.0,>=0.1.7 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.1.9)\n",
            "Requirement already satisfied: pandas<3.0.0,>=2.2.2 in /usr/local/lib/python3.10/dist-packages (from openagi) (2.2.2)\n",
            "Requirement already satisfied: pygithub<3.0.0,>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (2.3.0)\n",
            "Requirement already satisfied: pypdf<5.0.0,>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (4.3.1)\n",
            "Requirement already satisfied: pytest<9.0.0,>=8.2.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (8.3.2)\n",
            "Requirement already satisfied: python-dotenv<2.0.0,>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from openagi) (1.0.1)\n",
            "Requirement already satisfied: python-multipart<0.0.10,>=0.0.9 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.0.9)\n",
            "Requirement already satisfied: spacy==3.7.4 in /usr/local/lib/python3.10/dist-packages (from openagi) (3.7.4)\n",
            "Requirement already satisfied: spacytextblob<5.0.0,>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (4.0.0)\n",
            "Requirement already satisfied: sumy<0.12.0,>=0.11.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.11.0)\n",
            "Requirement already satisfied: transformers<5.0.0,>=4.40.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (4.42.4)\n",
            "Requirement already satisfied: uvicorn<0.30.0,>=0.29.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.29.0)\n",
            "Requirement already satisfied: wikipedia<2.0.0,>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from openagi) (1.4.0)\n",
            "Requirement already satisfied: xorbits<0.8.0,>=0.7.2 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.7.3)\n",
            "Requirement already satisfied: yfinance<0.3.0,>=0.2.37 in /usr/local/lib/python3.10/dist-packages (from openagi) (0.2.41)\n",
            "Requirement already satisfied: PyYAML>=5.3 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (6.0.2)\n",
            "Requirement already satisfied: SQLAlchemy<3,>=1.4 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (2.0.32)\n",
            "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (3.10.3)\n",
            "Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (4.0.3)\n",
            "Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (0.6.7)\n",
            "Requirement already satisfied: jsonpatch<2.0,>=1.33 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (1.33)\n",
            "Requirement already satisfied: langchain-core<0.2,>=0.1.24 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (0.1.52)\n",
            "Requirement already satisfied: langsmith<0.2.0,>=0.1.0 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (0.1.101)\n",
            "Requirement already satisfied: pydantic<3,>=1 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (2.8.2)\n",
            "Requirement already satisfied: requests<3,>=2 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (2.32.3)\n",
            "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /usr/local/lib/python3.10/dist-packages (from langchain==0.1.8->openagi) (8.5.0)\n",
            "Requirement already satisfied: openai<2.0.0,>=1.10.0 in /usr/local/lib/python3.10/dist-packages (from langchain-openai==0.0.6->openagi) (1.42.0)\n",
            "Requirement already satisfied: tiktoken<1,>=0.5.2 in /usr/local/lib/python3.10/dist-packages (from langchain-openai==0.0.6->openagi) (0.7.0)\n",
            "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (3.0.12)\n",
            "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (1.0.5)\n",
            "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (1.0.10)\n",
            "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (2.0.8)\n",
            "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (3.0.9)\n",
            "Requirement already satisfied: thinc<8.3.0,>=8.2.2 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (8.2.5)\n",
            "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (1.1.3)\n",
            "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (2.4.8)\n",
            "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (2.0.10)\n",
            "Requirement already satisfied: weasel<0.4.0,>=0.1.0 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (0.3.4)\n",
            "Requirement already satisfied: typer<0.10.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (0.9.4)\n",
            "Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (6.4.0)\n",
            "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (4.66.5)\n",
            "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (3.1.4)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (71.0.4)\n",
            "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (23.2)\n",
            "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /usr/local/lib/python3.10/dist-packages (from spacy==3.7.4->openagi) (3.4.0)\n",
            "Requirement already satisfied: azure-core>=1.23.0 in /usr/local/lib/python3.10/dist-packages (from azure-identity<2.0.0,>=1.15.0->openagi) (1.30.2)\n",
            "Requirement already satisfied: cryptography>=2.5 in /usr/local/lib/python3.10/dist-packages (from azure-identity<2.0.0,>=1.15.0->openagi) (42.0.8)\n",
            "Requirement already satisfied: msal>=1.24.0 in /usr/local/lib/python3.10/dist-packages (from azure-identity<2.0.0,>=1.15.0->openagi) (1.30.0)\n",
            "Requirement already satisfied: msal-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from azure-identity<2.0.0,>=1.15.0->openagi) (1.2.0)\n",
            "Requirement already satisfied: typing-extensions>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from azure-identity<2.0.0,>=1.15.0->openagi) (4.12.2)\n",
            "Requirement already satisfied: build>=1.0.3 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (1.2.1)\n",
            "Requirement already satisfied: chroma-hnswlib==0.7.6 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (0.7.6)\n",
            "Requirement already satisfied: posthog>=2.4.0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (3.5.2)\n",
            "Requirement already satisfied: onnxruntime>=1.14.1 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (1.19.0)\n",
            "Requirement already satisfied: opentelemetry-api>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (1.26.0)\n",
            "Requirement already satisfied: opentelemetry-exporter-otlp-proto-grpc>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (1.26.0)\n",
            "Requirement already satisfied: opentelemetry-instrumentation-fastapi>=0.41b0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (0.47b0)\n",
            "Requirement already satisfied: opentelemetry-sdk>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (1.26.0)\n",
            "Requirement already satisfied: tokenizers>=0.13.2 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (0.19.1)\n",
            "Requirement already satisfied: pypika>=0.48.9 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (0.48.9)\n",
            "Requirement already satisfied: overrides>=7.3.1 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (7.7.0)\n",
            "Requirement already satisfied: importlib-resources in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (6.4.2)\n",
            "Requirement already satisfied: grpcio>=1.58.0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (1.64.1)\n",
            "Requirement already satisfied: bcrypt>=4.0.1 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (4.2.0)\n",
            "Requirement already satisfied: kubernetes>=28.1.0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (30.1.0)\n",
            "Requirement already satisfied: mmh3>=4.0.1 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (4.1.0)\n",
            "Requirement already satisfied: orjson>=3.9.12 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (3.10.7)\n",
            "Requirement already satisfied: httpx>=0.27.0 in /usr/local/lib/python3.10/dist-packages (from chromadb<0.6.0,>=0.5.0->openagi) (0.27.0)\n",
            "Requirement already satisfied: click>=8.1.7 in /usr/local/lib/python3.10/dist-packages (from duckduckgo-search<7.0.0,>=6.1.0->openagi) (8.1.7)\n",
            "Requirement already satisfied: primp>=0.6.1 in /usr/local/lib/python3.10/dist-packages (from duckduckgo-search<7.0.0,>=6.1.0->openagi) (0.6.1)\n",
            "Requirement already satisfied: starlette<0.38.0,>=0.37.2 in /usr/local/lib/python3.10/dist-packages (from fastapi<0.111.0,>=0.110.0->openagi) (0.37.2)\n",
            "Requirement already satisfied: httplib2<1.dev0,>=0.19.0 in /usr/local/lib/python3.10/dist-packages (from google-api-python-client<3.0.0,>=2.121.0->openagi) (0.22.0)\n",
            "Requirement already satisfied: google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0 in /usr/local/lib/python3.10/dist-packages (from google-api-python-client<3.0.0,>=2.121.0->openagi) (2.27.0)\n",
            "Requirement already satisfied: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5 in /usr/local/lib/python3.10/dist-packages (from google-api-python-client<3.0.0,>=2.121.0->openagi) (2.19.1)\n",
            "Requirement already satisfied: uritemplate<5,>=3.0.1 in /usr/local/lib/python3.10/dist-packages (from google-api-python-client<3.0.0,>=2.121.0->openagi) (4.1.1)\n",
            "Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from google-auth-oauthlib<2.0.0,>=1.2.0->openagi) (1.3.1)\n",
            "Requirement already satisfied: exa-py<2.0.0,>=1.0.7 in /usr/local/lib/python3.10/dist-packages (from langchain-exa<0.0.2,>=0.0.1->openagi) (1.0.18)\n",
            "Requirement already satisfied: types-requests<3.0.0.0,>=2.31.0.2 in /usr/local/lib/python3.10/dist-packages (from langchainhub<0.2.0,>=0.1.15->openagi) (2.32.0.20240712)\n",
            "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0.0,>=2.2.2->openagi) (2.8.2)\n",
            "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0.0,>=2.2.2->openagi) (2024.1)\n",
            "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0.0,>=2.2.2->openagi) (2024.1)\n",
            "Requirement already satisfied: pynacl>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from pygithub<3.0.0,>=2.3.0->openagi) (1.5.0)\n",
            "Requirement already satisfied: pyjwt>=2.4.0 in /usr/local/lib/python3.10/dist-packages (from pyjwt[crypto]>=2.4.0->pygithub<3.0.0,>=2.3.0->openagi) (2.9.0)\n",
            "Requirement already satisfied: urllib3>=1.26.0 in /usr/local/lib/python3.10/dist-packages (from pygithub<3.0.0,>=2.3.0->openagi) (2.0.7)\n",
            "Requirement already satisfied: Deprecated in /usr/local/lib/python3.10/dist-packages (from pygithub<3.0.0,>=2.3.0->openagi) (1.2.14)\n",
            "Requirement already satisfied: iniconfig in /usr/local/lib/python3.10/dist-packages (from pytest<9.0.0,>=8.2.0->openagi) (2.0.0)\n",
            "Requirement already satisfied: pluggy<2,>=1.5 in /usr/local/lib/python3.10/dist-packages (from pytest<9.0.0,>=8.2.0->openagi) (1.5.0)\n",
            "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /usr/local/lib/python3.10/dist-packages (from pytest<9.0.0,>=8.2.0->openagi) (1.2.2)\n",
            "Requirement already satisfied: tomli>=1 in /usr/local/lib/python3.10/dist-packages (from pytest<9.0.0,>=8.2.0->openagi) (2.0.1)\n",
            "Requirement already satisfied: textblob<0.16.0,>=0.15.3 in /usr/local/lib/python3.10/dist-packages (from spacytextblob<5.0.0,>=4.0.0->openagi) (0.15.3)\n",
            "Requirement already satisfied: docopt<0.7,>=0.6.1 in /usr/local/lib/python3.10/dist-packages (from sumy<0.12.0,>=0.11.0->openagi) (0.6.2)\n",
            "Requirement already satisfied: breadability>=0.1.20 in /usr/local/lib/python3.10/dist-packages (from sumy<0.12.0,>=0.11.0->openagi) (0.1.20)\n",
            "Requirement already satisfied: pycountry>=18.2.23 in /usr/local/lib/python3.10/dist-packages (from sumy<0.12.0,>=0.11.0->openagi) (24.6.1)\n",
            "Requirement already satisfied: nltk>=3.0.2 in /usr/local/lib/python3.10/dist-packages (from sumy<0.12.0,>=0.11.0->openagi) (3.8.1)\n",
            "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.40.0->openagi) (3.15.4)\n",
            "Requirement already satisfied: huggingface-hub<1.0,>=0.23.2 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.40.0->openagi) (0.23.5)\n",
            "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.40.0->openagi) (2024.5.15)\n",
            "Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.40.0->openagi) (0.4.4)\n",
            "Requirement already satisfied: h11>=0.8 in /usr/local/lib/python3.10/dist-packages (from uvicorn<0.30.0,>=0.29.0->openagi) (0.14.0)\n",
            "Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.10/dist-packages (from wikipedia<2.0.0,>=1.4.0->openagi) (4.12.3)\n",
            "Requirement already satisfied: xoscar>=0.0.8 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (0.3.3)\n",
            "Requirement already satisfied: psutil>=5.9.0 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (5.9.5)\n",
            "Requirement already satisfied: tornado>=6.0 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (6.3.3)\n",
            "Requirement already satisfied: defusedxml>=0.5.0 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (0.7.1)\n",
            "Requirement already satisfied: pyarrow>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (14.0.2)\n",
            "Requirement already satisfied: fsspec!=2022.8.0,>=2022.7.1 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (2024.6.1)\n",
            "Requirement already satisfied: cloudpickle>=1.5.0 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (2.2.1)\n",
            "Requirement already satisfied: uvloop>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (0.20.0)\n",
            "Requirement already satisfied: scipy>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (1.13.1)\n",
            "Requirement already satisfied: scikit-learn>=1.1.3 in /usr/local/lib/python3.10/dist-packages (from xorbits<0.8.0,>=0.7.2->openagi) (1.3.2)\n",
            "Requirement already satisfied: multitasking>=0.0.7 in /usr/local/lib/python3.10/dist-packages (from yfinance<0.3.0,>=0.2.37->openagi) (0.0.11)\n",
            "Requirement already satisfied: lxml>=4.9.1 in /usr/local/lib/python3.10/dist-packages (from yfinance<0.3.0,>=0.2.37->openagi) (4.9.4)\n",
            "Requirement already satisfied: platformdirs>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from yfinance<0.3.0,>=0.2.37->openagi) (4.2.2)\n",
            "Requirement already satisfied: frozendict>=2.3.4 in /usr/local/lib/python3.10/dist-packages (from yfinance<0.3.0,>=0.2.37->openagi) (2.4.4)\n",
            "Requirement already satisfied: peewee>=3.16.2 in /usr/local/lib/python3.10/dist-packages (from yfinance<0.3.0,>=0.2.37->openagi) (3.17.6)\n",
            "Requirement already satisfied: html5lib>=1.1 in /usr/local/lib/python3.10/dist-packages (from yfinance<0.3.0,>=0.2.37->openagi) (1.1)\n",
            "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.1.8->openagi) (2.3.5)\n",
            "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.1.8->openagi) (1.3.1)\n",
            "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.1.8->openagi) (24.2.0)\n",
            "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.1.8->openagi) (1.4.1)\n",
            "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.1.8->openagi) (6.0.5)\n",
            "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.1.8->openagi) (1.9.4)\n",
            "Requirement already satisfied: six>=1.11.0 in /usr/local/lib/python3.10/dist-packages (from azure-core>=1.23.0->azure-identity<2.0.0,>=1.15.0->openagi) (1.16.0)\n",
            "Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4->wikipedia<2.0.0,>=1.4.0->openagi) (2.6)\n",
            "Requirement already satisfied: chardet in /usr/local/lib/python3.10/dist-packages (from breadability>=0.1.20->sumy<0.12.0,>=0.11.0->openagi) (5.2.0)\n",
            "Requirement already satisfied: pyproject_hooks in /usr/local/lib/python3.10/dist-packages (from build>=1.0.3->chromadb<0.6.0,>=0.5.0->openagi) (1.1.0)\n",
            "Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.10/dist-packages (from cryptography>=2.5->azure-identity<2.0.0,>=1.15.0->openagi) (1.17.0)\n",
            "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain==0.1.8->openagi) (3.22.0)\n",
            "Requirement already satisfied: typing-inspect<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain==0.1.8->openagi) (0.9.0)\n",
            "Requirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client<3.0.0,>=2.121.0->openagi) (1.63.2)\n",
            "Requirement already satisfied: protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0.dev0,>=3.19.5 in /usr/local/lib/python3.10/dist-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client<3.0.0,>=2.121.0->openagi) (3.20.3)\n",
            "Requirement already satisfied: proto-plus<2.0.0dev,>=1.22.3 in /usr/local/lib/python3.10/dist-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client<3.0.0,>=2.121.0->openagi) (1.24.0)\n",
            "Requirement already satisfied: cachetools<6.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0->google-api-python-client<3.0.0,>=2.121.0->openagi) (5.4.0)\n",
            "Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0->google-api-python-client<3.0.0,>=2.121.0->openagi) (0.4.0)\n",
            "Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.10/dist-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0->google-api-python-client<3.0.0,>=2.121.0->openagi) (4.9)\n",
            "Requirement already satisfied: webencodings in /usr/local/lib/python3.10/dist-packages (from html5lib>=1.1->yfinance<0.3.0,>=0.2.37->openagi) (0.5.1)\n",
            "Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in /usr/local/lib/python3.10/dist-packages (from httplib2<1.dev0,>=0.19.0->google-api-python-client<3.0.0,>=2.121.0->openagi) (3.1.2)\n",
            "Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx>=0.27.0->chromadb<0.6.0,>=0.5.0->openagi) (3.7.1)\n",
            "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx>=0.27.0->chromadb<0.6.0,>=0.5.0->openagi) (2024.7.4)\n",
            "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx>=0.27.0->chromadb<0.6.0,>=0.5.0->openagi) (1.0.5)\n",
            "Requirement already satisfied: idna in /usr/local/lib/python3.10/dist-packages (from httpx>=0.27.0->chromadb<0.6.0,>=0.5.0->openagi) (3.7)\n",
            "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx>=0.27.0->chromadb<0.6.0,>=0.5.0->openagi) (1.3.1)\n",
            "Requirement already satisfied: jsonpointer>=1.9 in /usr/local/lib/python3.10/dist-packages (from jsonpatch<2.0,>=1.33->langchain==0.1.8->openagi) (3.0.0)\n",
            "Requirement already satisfied: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in /usr/local/lib/python3.10/dist-packages (from kubernetes>=28.1.0->chromadb<0.6.0,>=0.5.0->openagi) (1.8.0)\n",
            "Requirement already satisfied: oauthlib>=3.2.2 in /usr/local/lib/python3.10/dist-packages (from kubernetes>=28.1.0->chromadb<0.6.0,>=0.5.0->openagi) (3.2.2)\n",
            "Requirement already satisfied: language-data>=1.2 in /usr/local/lib/python3.10/dist-packages (from langcodes<4.0.0,>=3.2.0->spacy==3.7.4->openagi) (1.2.0)\n",
            "Requirement already satisfied: portalocker<3,>=1.4 in /usr/local/lib/python3.10/dist-packages (from msal-extensions>=0.3.0->azure-identity<2.0.0,>=1.15.0->openagi) (2.10.1)\n",
            "Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk>=3.0.2->sumy<0.12.0,>=0.11.0->openagi) (1.4.2)\n",
            "Requirement already satisfied: coloredlogs in /usr/local/lib/python3.10/dist-packages (from onnxruntime>=1.14.1->chromadb<0.6.0,>=0.5.0->openagi) (15.0.1)\n",
            "Requirement already satisfied: flatbuffers in /usr/local/lib/python3.10/dist-packages (from onnxruntime>=1.14.1->chromadb<0.6.0,>=0.5.0->openagi) (24.3.25)\n",
            "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from onnxruntime>=1.14.1->chromadb<0.6.0,>=0.5.0->openagi) (1.13.2)\n",
            "Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai==0.0.6->openagi) (1.7.0)\n",
            "Requirement already satisfied: jiter<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai==0.0.6->openagi) (0.5.0)\n",
            "Requirement already satisfied: importlib-metadata<=8.0.0,>=6.0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-api>=1.2.0->chromadb<0.6.0,>=0.5.0->openagi) (8.0.0)\n",
            "Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from Deprecated->pygithub<3.0.0,>=2.3.0->openagi) (1.16.0)\n",
            "Requirement already satisfied: opentelemetry-exporter-otlp-proto-common==1.26.0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb<0.6.0,>=0.5.0->openagi) (1.26.0)\n",
            "Requirement already satisfied: opentelemetry-proto==1.26.0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.2.0->chromadb<0.6.0,>=0.5.0->openagi) (1.26.0)\n",
            "Requirement already satisfied: opentelemetry-instrumentation-asgi==0.47b0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-instrumentation-fastapi>=0.41b0->chromadb<0.6.0,>=0.5.0->openagi) (0.47b0)\n",
            "Requirement already satisfied: opentelemetry-instrumentation==0.47b0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-instrumentation-fastapi>=0.41b0->chromadb<0.6.0,>=0.5.0->openagi) (0.47b0)\n",
            "Requirement already satisfied: opentelemetry-semantic-conventions==0.47b0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-instrumentation-fastapi>=0.41b0->chromadb<0.6.0,>=0.5.0->openagi) (0.47b0)\n",
            "Requirement already satisfied: opentelemetry-util-http==0.47b0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-instrumentation-fastapi>=0.41b0->chromadb<0.6.0,>=0.5.0->openagi) (0.47b0)\n",
            "Requirement already satisfied: asgiref~=3.0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-instrumentation-asgi==0.47b0->opentelemetry-instrumentation-fastapi>=0.41b0->chromadb<0.6.0,>=0.5.0->openagi) (3.8.1)\n",
            "Requirement already satisfied: monotonic>=1.5 in /usr/local/lib/python3.10/dist-packages (from posthog>=2.4.0->chromadb<0.6.0,>=0.5.0->openagi) (1.6)\n",
            "Requirement already satisfied: backoff>=1.10.0 in /usr/local/lib/python3.10/dist-packages (from posthog>=2.4.0->chromadb<0.6.0,>=0.5.0->openagi) (2.2.1)\n",
            "Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain==0.1.8->openagi) (0.7.0)\n",
            "Requirement already satisfied: pydantic-core==2.20.1 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain==0.1.8->openagi) (2.20.1)\n",
            "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain==0.1.8->openagi) (3.3.2)\n",
            "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=1.1.3->xorbits<0.8.0,>=0.7.2->openagi) (3.5.0)\n",
            "Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy<3,>=1.4->langchain==0.1.8->openagi) (3.0.3)\n",
            "Requirement already satisfied: blis<0.8.0,>=0.7.8 in /usr/local/lib/python3.10/dist-packages (from thinc<8.3.0,>=8.2.2->spacy==3.7.4->openagi) (0.7.11)\n",
            "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from thinc<8.3.0,>=8.2.2->spacy==3.7.4->openagi) (0.1.5)\n",
            "Requirement already satisfied: httptools>=0.5.0 in /usr/local/lib/python3.10/dist-packages (from uvicorn[standard]>=0.18.3->chromadb<0.6.0,>=0.5.0->openagi) (0.6.1)\n",
            "Requirement already satisfied: watchfiles>=0.13 in /usr/local/lib/python3.10/dist-packages (from uvicorn[standard]>=0.18.3->chromadb<0.6.0,>=0.5.0->openagi) (0.23.0)\n",
            "Requirement already satisfied: websockets>=10.4 in /usr/local/lib/python3.10/dist-packages (from uvicorn[standard]>=0.18.3->chromadb<0.6.0,>=0.5.0->openagi) (13.0)\n",
            "Requirement already satisfied: cloudpathlib<0.17.0,>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from weasel<0.4.0,>=0.1.0->spacy==3.7.4->openagi) (0.16.0)\n",
            "Requirement already satisfied: tblib>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from xoscar>=0.0.8->xorbits<0.8.0,>=0.7.2->openagi) (3.0.0)\n",
            "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->spacy==3.7.4->openagi) (2.1.5)\n",
            "Requirement already satisfied: pycparser in /usr/local/lib/python3.10/dist-packages (from cffi>=1.12->cryptography>=2.5->azure-identity<2.0.0,>=1.15.0->openagi) (2.22)\n",
            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.10/dist-packages (from importlib-metadata<=8.0.0,>=6.0->opentelemetry-api>=1.2.0->chromadb<0.6.0,>=0.5.0->openagi) (3.20.0)\n",
            "Requirement already satisfied: marisa-trie>=0.7.7 in /usr/local/lib/python3.10/dist-packages (from language-data>=1.2->langcodes<4.0.0,>=3.2.0->spacy==3.7.4->openagi) (1.2.0)\n",
            "Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules>=0.2.1->google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0->google-api-python-client<3.0.0,>=2.121.0->openagi) (0.6.0)\n",
            "Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain==0.1.8->openagi) (1.0.0)\n",
            "Requirement already satisfied: humanfriendly>=9.1 in /usr/local/lib/python3.10/dist-packages (from coloredlogs->onnxruntime>=1.14.1->chromadb<0.6.0,>=0.5.0->openagi) (10.0)\n",
            "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from sympy->onnxruntime>=1.14.1->chromadb<0.6.0,>=0.5.0->openagi) (1.3.0)\n"
          ]
        }
      ],
      "source": [
        "pip install openagi"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "\n",
        "from openagi.actions.files import WriteFileAction, ReadFileAction\n",
        "from openagi.actions.tools.ddg_search import DuckDuckGoSearch\n",
        "from openagi.actions.tools.webloader import WebBaseContextTool\n",
        "from openagi.agent import Admin\n",
        "from openagi.llms.azure import AzureChatOpenAIModel\n",
        "from openagi.memory import Memory\n",
        "from openagi.planner.task_decomposer import TaskPlanner\n",
        "from openagi.worker import Worker\n",
        "from rich.console import Console\n",
        "from rich.markdown import Markdown\n"
      ],
      "metadata": {
        "id": "svWigR4SfN0R"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Environment Setup\n",
        "The script begins by setting up the necessary environment variables for Azure OpenAI services. This includes specifying the base URL, deployment name, model name, API key, and API version. These configurations are essential for authenticating and accessing the Azure OpenAI services."
      ],
      "metadata": {
        "id": "HB-AbFd_pnIk"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "if __name__ == \"__main__\":\n",
        "    import os\n",
        "\n",
        "    os.environ[\"AZURE_BASE_URL\"] = \" \"\n",
        "    os.environ[\"AZURE_DEPLOYMENT_NAME\"] = \" \"\n",
        "    os.environ[\"AZURE_MODEL_NAME\"] = \" \"\n",
        "    os.environ[\"AZURE_OPENAI_API_KEY\"] = \" \"\n",
        "    os.environ[\"AZURE_OPENAI_API_VERSION\"] = \" \"\n",
        "\n",
        "    config = AzureChatOpenAIModel.load_from_env_config()\n",
        "    llm = AzureChatOpenAIModel(config=config)"
      ],
      "metadata": {
        "id": "Bmp3U5qfgrbd"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Workers used:\n",
        "\n",
        "1. User Input Collector: The User Input Collector is responsible for gathering movie preferences from the user. It prompts the user to provide 2-3 movies they enjoy and asks for specific genres or themes associated with those films. This component ensures that the input is confirmed before proceeding to the recommendation phase.\n",
        "\n",
        "2. Movie Recommender: The Movie Recommender utilizes the user’s preferences to suggest similar movies. It analyzes the input from the User Input Collector, searches for related films using the DuckDuckGo search tool, and ranks the recommendations based on similarity and popularity. The output includes a structured list of recommended movies with descriptions.\n",
        "\n",
        "3. Recommendation Review Specialist: The Recommendation Review Specialist reviews the list of recommended movies to ensure clarity and relevance. This component checks the descriptions for engagement, suggests additional movies, and finalizes the presentation format for user readability."
      ],
      "metadata": {
        "id": "W85Fqy_ZpsiE"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "    user_input_collector = Worker(\n",
        "        role=\"User Input Collector\",\n",
        "        instructions=\"\"\"\n",
        "        Your task is to collect movie preferences from the user. Follow these steps:\n",
        "\n",
        "        1. Prompt the user to provide 2-3 movies they enjoy.\n",
        "\n",
        "        2. Ensure the user specifies the genres or themes they like about these movies.\n",
        "\n",
        "        3. Collect the input and prepare it for the recommendation process.\n",
        "\n",
        "        4. Confirm the collected preferences with the user before proceeding.\n",
        "\n",
        "        Your output should be the list of movies and their associated genres or themes.\n",
        "        \"\"\",\n",
        "        actions=[\n",
        "            DuckDuckGoSearch,\n",
        "            WebBaseContextTool,\n",
        "        ]\n",
        "    )\n",
        "\n",
        "    recommender = Worker(\n",
        "        role=\"Movie Recommender\",\n",
        "        instructions=\"\"\"\n",
        "        As a Movie Recommender, your task is to suggest movies based on the user's preferences. Follow these steps:\n",
        "\n",
        "        1. Receive the list of movies and genres/themes from the User Input Collector.\n",
        "\n",
        "        2. Use DuckDuckGoNewsSearch to find similar movies based on the provided input.\n",
        "\n",
        "        3. Analyze the search results for related films that match the user's tastes.\n",
        "\n",
        "        4. Rank the recommendations based on similarity and popularity.\n",
        "\n",
        "        5. Prepare a summary of the recommended movies, including a brief description of each.\n",
        "\n",
        "        6. Present the recommendations to the user in an engaging and informative manner.\n",
        "\n",
        "        Your output should be a structured list of recommended movies with descriptions.\n",
        "        \"\"\",\n",
        "        actions=[\n",
        "            DuckDuckGoSearch,\n",
        "            WebBaseContextTool,\n",
        "        ]\n",
        "    )\n",
        "\n",
        "    reviewer = Worker(\n",
        "        role=\"Recommendation Review Specialist\",\n",
        "        instructions=\"\"\"\n",
        "        As a meticulous reviewer, your task is to ensure the recommendations are relevant and well-presented. Follow these steps:\n",
        "\n",
        "        1. Review the list of recommended movies provided by the Movie Recommender.\n",
        "\n",
        "        2. Check for clarity: Ensure that each movie description is clear and engaging.\n",
        "\n",
        "        3. Suggest improvements: Recommend any additional movies that may fit the user's preferences.\n",
        "\n",
        "        4. Finalize the presentation: Ensure the output is formatted correctly for user readability.\n",
        "\n",
        "        Your output should be the final list of recommended movies with any suggested enhancements.\n",
        "        \"\"\",\n",
        "        actions=[\n",
        "            DuckDuckGoSearch,\n",
        "            WebBaseContextTool,\n",
        "        ]\n",
        "    )\n"
      ],
      "metadata": {
        "id": "_S1MLsthhN_h"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Admin\n",
        "The Admin  orchestrates the workflow by assigning tasks to the various workers. It manages the interaction between the user input collector, recommender, and reviewer, ensuring a smooth flow of information and user engagement."
      ],
      "metadata": {
        "id": "yYsXezclqH88"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "admin = Admin(\n",
        "        planner=TaskPlanner(human_intervene=True),\n",
        "        memory=Memory(),\n",
        "        llm=llm,\n",
        "    )\n",
        "\n",
        "admin.assign_workers([user_input_collector, recommender, reviewer])\n"
      ],
      "metadata": {
        "id": "Rvvle8XuhTOJ"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Execution\n",
        "Finally, the script runs the agent to collect user preferences and provide movie recommendations. The results are printed in a structured format, enhancing readability and user engagement."
      ],
      "metadata": {
        "id": "cU3xku6ZqPG0"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "   res = admin.run(\n",
        "        query=\"Recommend movies based on user preferences.\",\n",
        "        description=\"\"\"\n",
        "        The user will provide 2-3 movies they like along with their genres or themes.\n",
        "        Your task is to recommend similar movies based on this input.\n",
        "        Ensure to collect the user's preferences first and then provide a list of recommendations.\n",
        "        \"\"\"\n",
        "    )"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "wS69qO1MhZPs",
        "outputId": "57bc0e95-330a-4909-baf2-b86d26a7ed2c"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Agent: What specific genres or themes should I focus on when recommending movies based on the user's input?\n",
            "You: thriller and crime\n",
            "Agent: What specific movies should I ask the user for to gather their preferences?\n",
            "You: movies with suspense and thriller\n",
            "Agent: Could you specify what types of suspense and thriller elements the user prefers, such as psychological, action-packed, or character-driven?\n",
            "You: psychological \n",
            "Agent: What specific 2-3 movies should I ask the user for to gather their preferences in the thriller and crime genres?\n",
            "You: inception,parasite,shutter island\n",
            "Agent: What specific criteria should I use to determine if the recommended movies are similar to the user's preferences based on the provided movies?\n",
            "You: english movies\n",
            "Agent: Are there any specific elements or themes within thriller and crime movies, aside from psychological aspects, that the user prefers, such as character development or plot twists?\n",
            "You: no\n",
            "\n",
            "\n",
            "Tasks: [{'task_name': 'Collect User Movie Preferences', 'description': 'Prompt the user to provide 2-3 movies they enjoy and ask them to specify the genres or themes they like about these movies. Collect the input and confirm the preferences with the user.', 'worker_id': '29d59db9c64d4c7ebd76c215e1fe54e0'}, {'task_name': 'Recommend Movies Based on User Preferences', 'description': 'Receive the list of movies and genres/themes from the User Input Collector. Use DuckDuckGoSearch to find similar movies based on the provided input, analyze the results, rank the recommendations, and prepare a summary of the recommended movies.', 'worker_id': '8daebe52be894e988a2f4d4911e70d9b'}, {'task_name': 'Review Movie Recommendations', 'description': \"Review the list of recommended movies provided by the Movie Recommender. Ensure clarity and engagement of movie descriptions, suggest any additional movies that may fit the user's preferences, and finalize the presentation for user readability.\", 'worker_id': '5a471633bb394884813c035185a649d0'}]\n",
            "\n",
            "\n"
          ]
        },
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "WARNING:root:No Tasks to summarize.\n",
            "WARNING:chromadb.segment.impl.vector.local_persistent_hnsw:Number of requested results 10 is greater than number of elements in index 9, updating n_results = 9\n",
            "WARNING:root:No Tasks to summarize.\n",
            "WARNING:chromadb.segment.impl.vector.local_persistent_hnsw:Number of requested results 10 is greater than number of elements in index 9, updating n_results = 9\n",
            "WARNING:chromadb.segment.impl.vector.local_persistent_hnsw:Number of requested results 10 is greater than number of elements in index 9, updating n_results = 9\n",
            "WARNING:root:No Tasks to summarize.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Conclusion\n",
        "This demonstrates how to utilize the OpenAGI framework for building an interactive movie recommendation tool. By collecting user preferences and leveraging search capabilities, it provides personalized movie suggestions that enhance the user experience."
      ],
      "metadata": {
        "id": "U657GhGdqXi5"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(\"-\" * 100)\n",
        "Console().print(Markdown(res))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 322
        },
        "id": "z9ZYN7p4iLoM",
        "outputId": "eba254ac-4e6a-42ae-ed57-851b9200e583"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "----------------------------------------------------------------------------------------------------\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
              "┃                                               \u001b[1mRecommended Movies\u001b[0m                                                ┃\n",
              "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n",
              "\n",
              "Here are some movies you might enjoy:                                                                              \n",
              "\n",
              "\u001b[1;33m 1 \u001b[0m\u001b[1mInception\u001b[0m                                                                                                       \n",
              "\u001b[1;33m   \u001b[0mA mind-bending thriller that explores the world of dreams and the subconscious.                                 \n",
              "\u001b[1;33m 2 \u001b[0m\u001b[1mThe Shawshank Redemption\u001b[0m                                                                                        \n",
              "\u001b[1;33m   \u001b[0mA powerful story of hope and friendship set against the backdrop of a maximum-security prison.                  \n",
              "\u001b[1;33m 3 \u001b[0m\u001b[1mThe Godfather\u001b[0m                                                                                                   \n",
              "\u001b[1;33m   \u001b[0mAn iconic tale of family, power, and betrayal within the Italian-American mafia.                                \n",
              "\u001b[1;33m 4 \u001b[0m\u001b[1mParasite\u001b[0m                                                                                                        \n",
              "\u001b[1;33m   \u001b[0mA darkly comedic thriller that examines class disparity through the lives of two families.                      \n",
              "\u001b[1;33m 5 \u001b[0m\u001b[1mInterstellar\u001b[0m                                                                                                    \n",
              "\u001b[1;33m   \u001b[0mA visually stunning sci-fi epic about love, sacrifice, and the survival of humanity.                            \n",
              "\u001b[1;33m 6 \u001b[0m\u001b[1mThe Dark Knight\u001b[0m                                                                                                 \n",
              "\u001b[1;33m   \u001b[0mA gripping superhero film that delves into morality through the conflict between Batman and the Joker.          \n"
            ],
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
              "┃                                               <span style=\"font-weight: bold\">Recommended Movies</span>                                                ┃\n",
              "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n",
              "\n",
              "Here are some movies you might enjoy:                                                                              \n",
              "\n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Inception</span>                                                                                                       \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>A mind-bending thriller that explores the world of dreams and the subconscious.                                 \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">The Shawshank Redemption</span>                                                                                        \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>A powerful story of hope and friendship set against the backdrop of a maximum-security prison.                  \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">The Godfather</span>                                                                                                   \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>An iconic tale of family, power, and betrayal within the Italian-American mafia.                                \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span><span style=\"font-weight: bold\">Parasite</span>                                                                                                        \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>A darkly comedic thriller that examines class disparity through the lives of two families.                      \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span><span style=\"font-weight: bold\">Interstellar</span>                                                                                                    \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>A visually stunning sci-fi epic about love, sacrifice, and the survival of humanity.                            \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 6 </span><span style=\"font-weight: bold\">The Dark Knight</span>                                                                                                 \n",
              "<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>A gripping superhero film that delves into morality through the conflict between Batman and the Joker.          \n",
              "</pre>\n"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}