diff --git a/examples/cookbooks/rag_examples/agentic_rag/PraisonAI_RecipeAgent.ipynb b/examples/cookbooks/rag_examples/agentic_rag/PraisonAI_RecipeAgent.ipynb new file mode 100644 index 000000000..49f9cad0d --- /dev/null +++ b/examples/cookbooks/rag_examples/agentic_rag/PraisonAI_RecipeAgent.ipynb @@ -0,0 +1,481 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "LJRJRQtFTagH" + }, + "source": [ + "# AI RAG Agent with Web Access using PraisonAI" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Ph4RVTBCTcmB" + }, + "source": [ + "This notebook demonstrates how to build a Retrieval-Augmented Generation (RAG) agent with web access using GPT-4o and PraisonAI. The agent specializes in Thai recipes and can search the web for additional information." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "tMxfwPPATy_o" + }, + "source": [ + "This RAG agent:\n", + "* Creates an AI assistant specialized in Thai recipes and cooking\n", + "* Has access to a PDF knowledge base about Thai recipes\n", + "* Can search the web using DuckDuckGo for additional information\n", + "* Provides comprehensive answers about Thai cuisine\n", + "* Uses PraisonAI framework for agent management" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "h68oMaCITmqt" + }, + "source": [ + "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/rag_examples/agentic_rag/PraisonAI_RecipeAgent.ipynb)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cAdzoWXJUMfF" + }, + "source": [ + "# Dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "9D-2TlOrUNcu" + }, + "outputs": [], + "source": [ + "!pip install praisonaiagents openai requests" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "yY-4-kEIUW40" + }, + "source": [ + "# Set Up API Key" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "f5bhQ05yUX6J", + "outputId": "dcf9d0d9-332e-4136-9289-4c39d898005c" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Enter your OpenAI API key: ··········\n", + "✅ API key set successfully!\n" + ] + } + ], + "source": [ + "import os\n", + "\n", + "# Set your OpenAI API key here\n", + "os.environ['OPENAI_API_KEY'] = 'Enter your api key here'\n", + "\n", + "# Or use this method to input it securely\n", + "from getpass import getpass\n", + "api_key = getpass('Enter your OpenAI API key: ')\n", + "os.environ['OPENAI_API_KEY'] = api_key\n", + "\n", + "print(\"✅ API key set successfully!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Eh0j-SegUi13" + }, + "source": [ + "# Tools" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Z1A9oifIUkQN", + "outputId": "9be78226-36fa-43c4-865d-2f7e6e2ba9de" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✅ Tools imported successfully!\n" + ] + } + ], + "source": [ + "from praisonaiagents import Agent\n", + "import requests\n", + "import tempfile\n", + "from pathlib import Path\n", + "\n", + "print(\"✅ Tools imported successfully!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "efnnREHXUnYA" + }, + "source": [ + "# YAML Prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "kcM14-yQUqG-", + "outputId": "c5b6288d-a789-4a93-e20c-1d285370b667" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✅ Agent instructions configured!\n" + ] + } + ], + "source": [ + "# Agent configuration and instructions\n", + "AGENT_INSTRUCTIONS = \"\"\"\n", + "You are a helpful AI assistant specialized in Thai recipes and cooking.\n", + "\n", + "You have access to a PDF knowledge base about Thai recipes from: https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf\n", + "\n", + "You can also search the web for additional information about Thai cooking, ingredients, and techniques.\n", + "\n", + "When answering questions:\n", + "1. Use your knowledge about Thai cuisine to provide helpful information\n", + "2. If needed, search the web for additional details, current information, or clarification\n", + "3. Provide comprehensive, helpful answers about Thai cuisine\n", + "4. Always be informative and helpful about Thai cooking!\n", + "\n", + "You can use the internet_search function to search the web when needed.\n", + "\n", + "Focus on providing practical cooking advice, ingredient information, and authentic Thai recipe guidance.\n", + "\"\"\"\n", + "\n", + "print(\"✅ Agent instructions configured!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "MCBRcXFJUulY" + }, + "source": [ + "# Main" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "YaRLbgMmUvXv", + "outputId": "8ed8d9f8-85a7-48de-ccc6-f617cd672a85" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🤖 Thai Recipe RAG Agent created successfully!\n", + "The agent is ready to answer questions about Thai cooking.\n" + ] + } + ], + "source": [ + "# Create the RAG agent\n", + "rag_agent = Agent(\n", + " instructions=AGENT_INSTRUCTIONS,\n", + " llm=\"gpt-4o\",\n", + " markdown=True,\n", + " verbose=True\n", + ")\n", + "\n", + "print(\"🤖 Thai Recipe RAG Agent created successfully!\")\n", + "print(\"The agent is ready to answer questions about Thai cooking.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "QvZM94pGU0IX" + }, + "source": [ + "# Test the Agent" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000, + "referenced_widgets": [ + "47739975c9f04ee5b4e69e8f445cbeda", + "08888d583cba4c01b3fdf8f30b06ca4f" + ] + }, + "id": "QPdrleKxU1VN", + "outputId": "a71a86cd-eff8-4309-9b50-173a30066c90" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🤔 Question: What are the essential ingredients for Thai cooking?\n" + ] + }, + { + "data": { + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+       "                                                                                                                 \n",
+       "  👤 Agent: Agent                                                                                                \n",
+       "  Role: Assistant                                                                                                \n",
+       "                                                                                                                 \n",
+       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mAgent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "47739975c9f04ee5b4e69e8f445cbeda", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n"
+      ],
+      "text/plain": []
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "data": {
+      "text/html": [
+       "
\n",
+       "
\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Response generated in 8.4s\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[2mResponse generated in 8.4s\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+       " What are the essential ingredients for Thai cooking?                                                            \n",
+       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", + "\u001b[36m│\u001b[0m What are the essential ingredients for Thai cooking? \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+       " Thai cooking is known for its balance of five fundamental taste senses in each dish or the overall meal: sour,  \n",
+       " sweet, salty, bitter, and spicy. Essential ingredients that help achieve this balance include:                  \n",
+       "                                                                                                                 \n",
+       "   1 Fish Sauce (Nam Pla): A salty, savory sauce made from fermented fish. It's a cornerstone of Thai cooking,   \n",
+       "     used to add depth of flavor.                                                                                \n",
+       "   2 Lime Juice: Used to add a fresh, tangy citrus flavor to dishes, especially in salads and some curries.      \n",
+       "   3 Chilies: Thai cuisine often features fresh Thai bird's eye chilies for heat, as well as dried chilies for   \n",
+       "     certain recipes.                                                                                            \n",
+       "   4 Lemongrass: A citrusy, fragrant herb that is often used in soups, curries, and teas.                        \n",
+       "   5 Galangal: Similar to ginger, galangal has a sharp, peppery flavor and is used in soups and curries.         \n",
+       "   6 Kaffir Lime Leaves: They add a distinct, zesty citrus aroma and flavor to Thai dishes.                      \n",
+       "   7 Coconut Milk: Adds richness and creaminess, commonly used in curries and desserts.                          \n",
+       "   8 Palm Sugar: Used as a sweetener, palm sugar has a nuanced flavor, unlike regular sugar.                     \n",
+       "   9 Tamarind Paste: Provides a sour element to many dishes, particularly pad Thai and some sauces.              \n",
+       "  10 Thai Basil: Adds a spicy, peppery flavor, different from the sweet basil used in Western cooking.           \n",
+       "  11 Coriander (Cilantro): Used as a garnish and for its fresh, citrusy leaves and roots, which add depth to     \n",
+       "     sauces and stocks.                                                                                          \n",
+       "  12 Shrimp Paste: A very pungent paste made from fermented shrimp, used sparingly to enrich the flavor of       \n",
+       "     dishes.                                                                                                     \n",
+       "                                                                                                                 \n",
+       " These ingredients are commonly used in combination to create the complex and rich flavors characteristic of     \n",
+       " Thai cuisine. Fresh and high-quality versions of these ingredients contribute significantly to the authenticity \n",
+       " of Thai dishes.                                                                                                 \n",
+       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", + "\u001b[36m│\u001b[0m Thai cooking is known for its balance of five fundamental taste senses in each dish or the overall meal: sour, \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m sweet, salty, bitter, and spicy. Essential ingredients that help achieve this balance include: \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 1 \u001b[0m\u001b[1mFish Sauce (Nam Pla)\u001b[0m: A salty, savory sauce made from fermented fish. It's a cornerstone of Thai cooking, \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mused to add depth of flavor. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mLime Juice\u001b[0m: Used to add a fresh, tangy citrus flavor to dishes, especially in salads and some curries. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mChilies\u001b[0m: Thai cuisine often features fresh Thai bird's eye chilies for heat, as well as dried chilies for \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mcertain recipes. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mLemongrass\u001b[0m: A citrusy, fragrant herb that is often used in soups, curries, and teas. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mGalangal\u001b[0m: Similar to ginger, galangal has a sharp, peppery flavor and is used in soups and curries. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 6 \u001b[0m\u001b[1mKaffir Lime Leaves\u001b[0m: They add a distinct, zesty citrus aroma and flavor to Thai dishes. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 7 \u001b[0m\u001b[1mCoconut Milk\u001b[0m: Adds richness and creaminess, commonly used in curries and desserts. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 8 \u001b[0m\u001b[1mPalm Sugar\u001b[0m: Used as a sweetener, palm sugar has a nuanced flavor, unlike regular sugar. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 9 \u001b[0m\u001b[1mTamarind Paste\u001b[0m: Provides a sour element to many dishes, particularly pad Thai and some sauces. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 10 \u001b[0m\u001b[1mThai Basil\u001b[0m: Adds a spicy, peppery flavor, different from the sweet basil used in Western cooking. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 11 \u001b[0m\u001b[1mCoriander (Cilantro)\u001b[0m: Used as a garnish and for its fresh, citrusy leaves and roots, which add depth to \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0msauces and stocks. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 12 \u001b[0m\u001b[1mShrimp Paste\u001b[0m: A very pungent paste made from fermented shrimp, used sparingly to enrich the flavor of \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mdishes. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m These ingredients are commonly used in combination to create the complex and rich flavors characteristic of \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Thai cuisine. Fresh and high-quality versions of these ingredients contribute significantly to the authenticity \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m of Thai dishes. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "�� Answer: Thai cooking is known for its balance of five fundamental taste senses in each dish or the overall meal: sour, sweet, salty, bitter, and spicy. Essential ingredients that help achieve this balance include:\n", + "\n", + "1. **Fish Sauce (Nam Pla)**: A salty, savory sauce made from fermented fish. It's a cornerstone of Thai cooking, used to add depth of flavor.\n", + "\n", + "2. **Lime Juice**: Used to add a fresh, tangy citrus flavor to dishes, especially in salads and some curries.\n", + "\n", + "3. **Chilies**: Thai cuisine often features fresh Thai bird's eye chilies for heat, as well as dried chilies for certain recipes.\n", + "\n", + "4. **Lemongrass**: A citrusy, fragrant herb that is often used in soups, curries, and teas.\n", + "\n", + "5. **Galangal**: Similar to ginger, galangal has a sharp, peppery flavor and is used in soups and curries.\n", + "\n", + "6. **Kaffir Lime Leaves**: They add a distinct, zesty citrus aroma and flavor to Thai dishes.\n", + "\n", + "7. **Coconut Milk**: Adds richness and creaminess, commonly used in curries and desserts.\n", + "\n", + "8. **Palm Sugar**: Used as a sweetener, palm sugar has a nuanced flavor, unlike regular sugar.\n", + "\n", + "9. **Tamarind Paste**: Provides a sour element to many dishes, particularly pad Thai and some sauces.\n", + "\n", + "10. **Thai Basil**: Adds a spicy, peppery flavor, different from the sweet basil used in Western cooking.\n", + "\n", + "11. **Coriander (Cilantro)**: Used as a garnish and for its fresh, citrusy leaves and roots, which add depth to sauces and stocks.\n", + "\n", + "12. **Shrimp Paste**: A very pungent paste made from fermented shrimp, used sparingly to enrich the flavor of dishes.\n", + "\n", + "These ingredients are commonly used in combination to create the complex and rich flavors characteristic of Thai cuisine. Fresh and high-quality versions of these ingredients contribute significantly to the authenticity of Thai dishes.\n" + ] + } + ], + "source": [ + "# Test question 1: Basic Thai cooking\n", + "question1 = \"What are the essential ingredients for Thai cooking?\"\n", + "print(f\"🤔 Question: {question1}\")\n", + "\n", + "try:\n", + " response1 = rag_agent.start(question1)\n", + " print(f\"�� Answer: {response1}\")\n", + "except Exception as e:\n", + " print(f\"❌ Error: {e}\")" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/examples/cookbooks/rag_examples/agentic_rag/agentic_rag_gpt5_praisonai_agents.ipynb b/examples/cookbooks/rag_examples/agentic_rag/agentic_rag_gpt5_praisonai_agents.ipynb new file mode 100644 index 000000000..713f99ce7 --- /dev/null +++ b/examples/cookbooks/rag_examples/agentic_rag/agentic_rag_gpt5_praisonai_agents.ipynb @@ -0,0 +1,556 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "EA8l4cSVl3Lx" + }, + "source": [ + "# Agentic RAG with GPT-5 - Colab Notebook" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "I-8nOxJ2l7nO" + }, + "source": [ + "This Colab notebook sets up a Streamlit app using PraisonAI Agents framework.\n", + "It allows you to interact with an AI agent powered by GPT-5 for Q&A.\n", + "Currently, the knowledge base functionality is disabled due to compatibility issues." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "g5I1tMkxmDQe" + }, + "source": [ + "- GPT-5 Integration (via OpenAI API)\n", + "- Streamlit Web App\n", + "- Agent Framework: PraisonAI Agents\n", + "- Markdown-formatted responses" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "yeEno7U0q2U_" + }, + "source": [ + "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Dhivya-Bharathy/PraisonAI/blob/main/examples/cookbooks/Qwen2.5_InstructionAgent.ipynb)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WV2GnzZCmGBR" + }, + "source": [ + "# Dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "20wAadXemJ0k" + }, + "outputs": [], + "source": [ + "!pip install praisonaiagents python-dotenv streamlit" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "l71uCRarndvy" + }, + "source": [ + "# Set API Key" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "id": "brfc-ZZKnfre" + }, + "outputs": [], + "source": [ + "import os\n", + "from dotenv import load_dotenv\n", + "\n", + "load_dotenv()\n", + "\n", + "OPENAI_API_KEY = \"Enter your api key here\"\n", + "\n", + "os.environ[\"OPENAI_API_KEY\"] = OPENAI_API_KEY\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "d1fGzyQCn1aQ" + }, + "source": [ + "# Tools and Imports" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "id": "GcNPLkZXntIS" + }, + "outputs": [], + "source": [ + "import streamlit as st\n", + "from praisonaiagents import Agent\n", + "\n", + "# YAML Prompt Configuration\n", + "agent_config = {\n", + " \"name\": \"Knowledge Agent\",\n", + " \"instructions\": [\n", + " \"You are a helpful AI assistant. Answer questions based on your general knowledge.\",\n", + " \"Provide clear, well-structured answers in markdown format.\",\n", + " \"Use proper markdown formatting with headers, lists, and emphasis where appropriate.\",\n", + " \"Structure your response with clear sections and bullet points when helpful.\",\n", + " ],\n", + " \"llm\": \"gpt-5-nano\",\n", + " \"markdown\": True,\n", + " \"verbose\": True\n", + "}\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "jkmrh0gIn_4a" + }, + "source": [ + "# Initialize Agent" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "qaJvf8RyoAsB" + }, + "outputs": [], + "source": [ + "def create_agent():\n", + " \"\"\"Create an agent with reasoning capabilities\"\"\"\n", + " return Agent(\n", + " name=agent_config[\"name\"],\n", + " instructions=agent_config[\"instructions\"],\n", + " llm=agent_config[\"llm\"],\n", + " markdown=agent_config[\"markdown\"],\n", + " verbose=agent_config[\"verbose\"]\n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "kvGJh3bbqTmh" + }, + "source": [ + "# Main Function" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000, + "referenced_widgets": [ + "ad296d97510246de8eb0138ce8a8a166", + "f6e502b3dca442f0ae6c5739f5a6d159" + ] + }, + "id": "_QyxzqKKqUrW", + "outputId": "97be7e02-b034-4004-e9e3-56337e3f2887" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "�� Initializing Agentic RAG with GPT-5...\n", + "📚 Loading agent...\n", + "✅ Agent loaded successfully!\n", + "\n", + "🎯 Example queries you can try:\n", + "1. What is PraisonAI and how do Agents work?\n", + "2. What are Teams in PraisonAI and how do they work?\n", + "3. Give me a step-by-step guide to building a RAG system.\n", + "4. What are AI Agents?\n", + "\n", + "============================================================\n", + "\n", + "🤔 Enter your question (or 'quit' to exit):\n", + "> What is PraisonAI and how do Agents work?\n", + "🔍 Processing your question...\n" + ] + }, + { + "data": { + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+       "                                                                                                                 \n",
+       "  👤 Agent: Knowledge Agent                                                                                      \n",
+       "  Role: Assistant                                                                                                \n",
+       "                                                                                                                 \n",
+       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[38;2;210;227;200m╭─\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[1;38;2;210;227;200mAgent Info\u001b[0m\u001b[38;2;210;227;200m \u001b[0m\u001b[38;2;210;227;200m───────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;210;227;200m─╮\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;255;155;155m👤 Agent:\u001b[0m \u001b[38;2;255;229;229mKnowledge Agent\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[1;38;2;180;180;179mRole:\u001b[0m \u001b[38;2;255;229;229mAssistant\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m│\u001b[0m \u001b[38;2;210;227;200m│\u001b[0m\n", + "\u001b[38;2;210;227;200m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "ad296d97510246de8eb0138ce8a8a166", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n"
+      ],
+      "text/plain": []
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "data": {
+      "text/html": [
+       "
\n",
+       "
\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Response generated in 9.4s\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[2mResponse generated in 9.4s\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+       " What is PraisonAI and how do Agents work?                                                                       \n",
+       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[36m╭─\u001b[0m\u001b[36m────────────────────────────────────────────────────\u001b[0m\u001b[36m Task \u001b[0m\u001b[36m─────────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", + "\u001b[36m│\u001b[0m What is PraisonAI and how do Agents work? \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+       " ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ \n",
+       "What is PraisonAI?\n",
+       " ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ \n",
+       "                                                                                                                 \n",
+       " PraisonAI is a platform designed to leverage artificial intelligence to enhance personal and business           \n",
+       " productivity. It typically involves developing AI models that can assist in various tasks, automate processes,  \n",
+       " and provide insights based on data analysis.                                                                    \n",
+       "                                                                                                                 \n",
+       "                                                                                                                 \n",
+       "                                            Key Features of PraisonAI                                            \n",
+       "                                                                                                                 \n",
+       " Task Automation: Automates repetitive tasks, allowing users to focus on more strategic activities.           \n",
+       " Data Insights: Analyzes large sets of data to provide actionable insights.                                   \n",
+       " Natural Language Processing: Enables users to interact with the AI through natural language, making it       \n",
+       "    user-friendly.                                                                                               \n",
+       " Customizable Solutions: Tailors AI applications to meet specific user needs across various industries.       \n",
+       "                                                                                                                 \n",
+       " ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ \n",
+       "How Do Agents Work in PraisonAI?\n",
+       " ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ \n",
+       "                                                                                                                 \n",
+       " Agents in PraisonAI refer to autonomous or semi-autonomous AI systems that perform designated tasks or          \n",
+       " functions. Here’s how they typically operate:                                                                   \n",
+       "                                                                                                                 \n",
+       "                                                                                                                 \n",
+       "                                               1. Types of Agents                                                \n",
+       "                                                                                                                 \n",
+       " Reactive Agents: Respond to the current environment without internal memory. They act solely based on        \n",
+       "    current inputs.                                                                                              \n",
+       " Deliberative Agents: Have a model of their environment, plan their actions, and retain memories of past      \n",
+       "    interactions.                                                                                                \n",
+       " Learning Agents: Improve their performance over time through experience, adapting to new information.        \n",
+       "                                                                                                                 \n",
+       "                                                                                                                 \n",
+       "                                           2. Functionality of Agents                                            \n",
+       "                                                                                                                 \n",
+       " Task Execution: Agents can carry out specific tasks as programmed, such as scheduling, data entry, or        \n",
+       "    customer support.                                                                                            \n",
+       " Interaction: They often interact with users through chat interfaces or APIs, providing a seamless user       \n",
+       "    experience.                                                                                                  \n",
+       " Integration: Can be integrated with other systems or software to enhance functionality, such as CRM systems, \n",
+       "    databases, or other AI tools.                                                                                \n",
+       " Continuous Learning: Agents may utilize machine learning algorithms to adapt and evolve based on user        \n",
+       "    interactions and data received.                                                                              \n",
+       "                                                                                                                 \n",
+       "                                                                                                                 \n",
+       "                                           3. Benefits of Using Agents                                           \n",
+       "                                                                                                                 \n",
+       " Increased Efficiency: Automate routine tasks to reduce workload.                                             \n",
+       " 24/7 Availability: Provide consistent support and functionality without downtime.                            \n",
+       " Scalability: Easily scale operations by deploying more agents as needed.                                     \n",
+       " Data-Driven Decisions: Use data insights to inform strategy and operations.                                  \n",
+       "                                                                                                                 \n",
+       "                                                                                                                 \n",
+       "                                                   Conclusion                                                    \n",
+       "                                                                                                                 \n",
+       " PraisonAI represents a robust platform for enhancing productivity through AI, with agents serving as the heart  \n",
+       " of this solution, performing various tasks and supporting users in achieving their goals efficiently. Whether   \n",
+       " they are simple reactive agents or complex learning entities, their design focuses on making operations         \n",
+       " smoother and more effective.                                                                                    \n",
+       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[36m╭─\u001b[0m\u001b[36m──────────────────────────────────────────────────\u001b[0m\u001b[36m Response \u001b[0m\u001b[36m───────────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", + "\u001b[36m│\u001b[0m ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m ┃ \u001b[1mWhat is PraisonAI?\u001b[0m ┃ \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m PraisonAI is a platform designed to leverage artificial intelligence to enhance personal and business \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m productivity. It typically involves developing AI models that can assist in various tasks, automate processes, \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m and provide insights based on data analysis. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;4mKey Features of PraisonAI\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mTask Automation\u001b[0m: Automates repetitive tasks, allowing users to focus on more strategic activities. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mData Insights\u001b[0m: Analyzes large sets of data to provide actionable insights. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mNatural Language Processing\u001b[0m: Enables users to interact with the AI through natural language, making it \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0muser-friendly. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mCustomizable Solutions\u001b[0m: Tailors AI applications to meet specific user needs across various industries. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m ┃ \u001b[1mHow Do Agents Work in PraisonAI?\u001b[0m ┃ \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Agents in PraisonAI refer to autonomous or semi-autonomous AI systems that perform designated tasks or \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m functions. Here’s how they typically operate: \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;4m1. \u001b[0m\u001b[1;4mTypes of Agents\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mReactive Agents\u001b[0m: Respond to the current environment without internal memory. They act solely based on \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mcurrent inputs. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mDeliberative Agents\u001b[0m: Have a model of their environment, plan their actions, and retain memories of past \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0minteractions. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mLearning Agents\u001b[0m: Improve their performance over time through experience, adapting to new information. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;4m2. \u001b[0m\u001b[1;4mFunctionality of Agents\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mTask Execution\u001b[0m: Agents can carry out specific tasks as programmed, such as scheduling, data entry, or \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mcustomer support. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mInteraction\u001b[0m: They often interact with users through chat interfaces or APIs, providing a seamless user \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mexperience. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mIntegration\u001b[0m: Can be integrated with other systems or software to enhance functionality, such as CRM systems, \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mdatabases, or other AI tools. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mContinuous Learning\u001b[0m: Agents may utilize machine learning algorithms to adapt and evolve based on user \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0minteractions and data received. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;4m3. \u001b[0m\u001b[1;4mBenefits of Using Agents\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mIncreased Efficiency\u001b[0m: Automate routine tasks to reduce workload. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1m24/7 Availability\u001b[0m: Provide consistent support and functionality without downtime. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mScalability\u001b[0m: Easily scale operations by deploying more agents as needed. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m • \u001b[0m\u001b[1mData-Driven Decisions\u001b[0m: Use data insights to inform strategy and operations. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;4mConclusion\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m PraisonAI represents a robust platform for enhancing productivity through AI, with agents serving as the heart \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m of this solution, performing various tasks and supporting users in achieving their goals efficiently. Whether \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m they are simple reactive agents or complex learning entities, their design focuses on making operations \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m smoother and more effective. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "💡 Answer:\n", + "========================================\n", + "# What is PraisonAI?\n", + "\n", + "PraisonAI is a platform designed to leverage artificial intelligence to enhance personal and business productivity. It typically involves developing AI models that can assist in various tasks, automate processes, and provide insights based on data analysis.\n", + "\n", + "## Key Features of PraisonAI\n", + "\n", + "- **Task Automation**: Automates repetitive tasks, allowing users to focus on more strategic activities.\n", + "- **Data Insights**: Analyzes large sets of data to provide actionable insights.\n", + "- **Natural Language Processing**: Enables users to interact with the AI through natural language, making it user-friendly.\n", + "- **Customizable Solutions**: Tailors AI applications to meet specific user needs across various industries.\n", + "\n", + "# How Do Agents Work in PraisonAI?\n", + "\n", + "Agents in PraisonAI refer to autonomous or semi-autonomous AI systems that perform designated tasks or functions. Here’s how they typically operate:\n", + "\n", + "## 1. **Types of Agents**\n", + "\n", + "- **Reactive Agents**: Respond to the current environment without internal memory. They act solely based on current inputs.\n", + "- **Deliberative Agents**: Have a model of their environment, plan their actions, and retain memories of past interactions.\n", + "- **Learning Agents**: Improve their performance over time through experience, adapting to new information.\n", + "\n", + "## 2. **Functionality of Agents**\n", + "\n", + "- **Task Execution**: Agents can carry out specific tasks as programmed, such as scheduling, data entry, or customer support.\n", + "- **Interaction**: They often interact with users through chat interfaces or APIs, providing a seamless user experience.\n", + "- **Integration**: Can be integrated with other systems or software to enhance functionality, such as CRM systems, databases, or other AI tools.\n", + "- **Continuous Learning**: Agents may utilize machine learning algorithms to adapt and evolve based on user interactions and data received.\n", + "\n", + "## 3. **Benefits of Using Agents**\n", + "\n", + "- **Increased Efficiency**: Automate routine tasks to reduce workload.\n", + "- **24/7 Availability**: Provide consistent support and functionality without downtime.\n", + "- **Scalability**: Easily scale operations by deploying more agents as needed.\n", + "- **Data-Driven Decisions**: Use data insights to inform strategy and operations.\n", + "\n", + "## Conclusion\n", + "\n", + "PraisonAI represents a robust platform for enhancing productivity through AI, with agents serving as the heart of this solution, performing various tasks and supporting users in achieving their goals efficiently. Whether they are simple reactive agents or complex learning entities, their design focuses on making operations smoother and more effective.\n", + "========================================\n", + "\n", + "🤔 Enter your question (or 'quit' to exit):\n", + "> quit\n", + "👋 Goodbye!\n" + ] + } + ], + "source": [ + "def main():\n", + " print(\"�� Initializing Agentic RAG with GPT-5...\")\n", + "\n", + " # Check if API key is set\n", + " if not OPENAI_API_KEY or OPENAI_API_KEY == \"your_openai_api_key_here\":\n", + " print(\"❌ Please set your OpenAI API key first!\")\n", + " print(\"�� Get your key from: https://platform.openai.com/\")\n", + " return\n", + "\n", + " try:\n", + " # Create agent\n", + " print(\"📚 Loading agent...\")\n", + " agent = create_agent()\n", + " print(\"✅ Agent loaded successfully!\")\n", + "\n", + " # Example queries\n", + " example_queries = [\n", + " \"What is PraisonAI and how do Agents work?\",\n", + " \"What are Teams in PraisonAI and how do they work?\",\n", + " \"Give me a step-by-step guide to building a RAG system.\",\n", + " \"What are AI Agents?\"\n", + " ]\n", + "\n", + " print(\"\\n🎯 Example queries you can try:\")\n", + " for i, query in enumerate(example_queries, 1):\n", + " print(f\"{i}. {query}\")\n", + "\n", + " print(\"\\n\" + \"=\"*60)\n", + "\n", + " # Interactive query loop\n", + " while True:\n", + " print(\"\\n🤔 Enter your question (or 'quit' to exit):\")\n", + " user_query = input(\"> \")\n", + "\n", + " if user_query.lower() in ['quit', 'exit', 'q']:\n", + " print(\"👋 Goodbye!\")\n", + " break\n", + "\n", + " if user_query.strip():\n", + " print(\"🔍 Processing your question...\")\n", + " try:\n", + " response = agent.start(user_query)\n", + " print(\"\\n💡 Answer:\")\n", + " print(\"=\"*40)\n", + " print(response)\n", + " print(\"=\"*40)\n", + " except Exception as e:\n", + " print(f\"❌ Error: {str(e)}\")\n", + " print(f\"🔍 Error type: {type(e).__name__}\")\n", + " print(\"💡 This might be due to API issues or model access problems.\")\n", + " else:\n", + " print(\"❌ Please enter a valid question.\")\n", + "\n", + " except Exception as e:\n", + " print(f\"❌ Failed to initialize agent: {str(e)}\")\n", + " print(\"�� Make sure your API key is correct and you have sufficient credits.\")\n", + "\n", + "# Run the main function\n", + "if __name__ == \"__main__\":\n", + " main()" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}