{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "vasmnCHdNDWd"
      },
      "outputs": [],
      "source": [
        "!pip install openagi"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install langchain_groq"
      ],
      "metadata": {
        "id": "3wdRU-85Nojh"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Import the statements"
      ],
      "metadata": {
        "id": "HmmaLO3IQO1n"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from openagi.actions.tools.ddg_search import DuckDuckGoSearch\n",
        "from openagi.agent import Admin\n",
        "from openagi.llms.groq import GroqModel\n",
        "from openagi.memory import Memory\n",
        "from openagi.planner.task_decomposer import TaskPlanner"
      ],
      "metadata": {
        "id": "LcPvbxzJNuwt"
      },
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Setup Groq LLM and save variables in environment"
      ],
      "metadata": {
        "id": "j-02wMLtQRUY"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import os\n",
        "\n",
        "os.environ['GROQ_API_KEY'] = \"<replace-with-groq-api>\"\n",
        "os.environ['GROQ_MODEL'] = \"mixtral-8x7b-32768\"\n",
        "os.environ['GROQ_TEMP'] = \"0.1\""
      ],
      "metadata": {
        "id": "wxoJm6iNN7W5"
      },
      "execution_count": 27,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "config = GroqModel.load_from_env_config()\n",
        "llm = GroqModel(config=config)"
      ],
      "metadata": {
        "id": "RQ7JIPyvONBW"
      },
      "execution_count": 28,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Define Task Planner and Action"
      ],
      "metadata": {
        "id": "lDMn2maZSvUM"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "planner = TaskPlanner(human_intervene=False)\n",
        "action = DuckDuckGoSearch"
      ],
      "metadata": {
        "id": "MYMCR434OSbQ"
      },
      "execution_count": 29,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Define Admin"
      ],
      "metadata": {
        "id": "WYbrqtUvS1H0"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "admin = Admin(\n",
        "    actions= [action],\n",
        "    planner = planner,\n",
        "    memory=Memory(),\n",
        "    llm = llm,\n",
        "    max_iterations = 5\n",
        ")"
      ],
      "metadata": {
        "id": "V-yuGi8AOlct"
      },
      "execution_count": 31,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "res = admin.run(\n",
        "    query=\"3 Days Trip to San francisco Bay area\",\n",
        "    description=\"You are a knowledgeable local guide with extensive information about the city, it's attractions and customs\",\n",
        ")"
      ],
      "metadata": {
        "id": "DQz6XN4qOww-"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "print(res)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "HnrZNnkkQF7C",
        "outputId": "dd9c9d63-f9c9-489b-d588-a628090e0f22"
      },
      "execution_count": 33,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Here is the requested 3-day itinerary for San Francisco in markdown format:\n",
            "\n",
            "```markdown\n",
            "Here is a 3-day itinerary for San Francisco that takes into account local customs and etiquette:\n",
            "\n",
            "## Day 1\n",
            "- Morning: Visit the Golden Gate Bridge and Park. Remember to respect the natural surroundings and other visitors.\n",
            "- Afternoon: Explore Fisherman's Wharf and Pier 39. Be mindful of the sea lions and their space.\n",
            "- Evening: Have dinner in Chinatown. Follow local dining etiquette and be respectful of the culture.\n",
            "\n",
            "## Day 2\n",
            "- Morning: Take a stroll through the Presidio and visit the Walt Disney Family Museum. Dress appropriately for the weather and be respectful of the museum's rules.\n",
            "- Afternoon: Visit the Exploratorium or California Academy of Sciences. Follow the institutions' guidelines and be considerate of other visitors.\n",
            "- Evening: Enjoy a meal in the Mission District. Familiarize yourself with local customs and try some authentic Mexican cuisine.\n",
            "\n",
            "## Day 3\n",
            "- Morning: Ride a cable car and visit Lombard Street. Follow traffic rules and be respectful of residents and other tourists.\n",
            "- Afternoon: Explore the Haight-Ashbury neighborhood and the Golden Gate Park. Respect the local culture and the environment.\n",
            "- Evening: Have dinner in North Beach, also known as Little Italy. Be aware of local dining etiquette and try some Italian-American dishes.\n",
            "```\n",
            "I hope you find this itinerary helpful and enjoy your trip to San Francisco!\n"
          ]
        }
      ]
    }
  ]
}