/ examples / cookbooks / Research_Knowledge_QA_Agents / KnowledgeAgent_PraisonAI.ipynb
KnowledgeAgent_PraisonAI.ipynb
  1  {
  2   "cells": [
  3    {
  4     "cell_type": "markdown",
  5     "id": "127dc323",
  6     "metadata": {
  7      "id": "127dc323"
  8     },
  9     "source": [
 10      "# ๐Ÿ“˜ KnowledgeAgent - AI-Powered Content Analysis and Summarization Tool"
 11     ]
 12    },
 13    {
 14     "cell_type": "markdown",
 15     "id": "8290ecb7",
 16     "metadata": {
 17      "id": "8290ecb7"
 18     },
 19     "source": [
 20      "\n",
 21      "This notebook demonstrates how to create an AI-powered **KnowledgeAgent** using the [PraisonAI](https://github.com/MervinPraison/PraisonAI/) framework.  \n",
 22      "The agent performs content analysis and summarization tasks using LLMs and a vector database.  \n",
 23      "Runs on Google Colab free tier.\n"
 24     ]
 25    },
 26    {
 27     "cell_type": "markdown",
 28     "id": "Lxx3NiCrpFNM",
 29     "metadata": {
 30      "id": "Lxx3NiCrpFNM"
 31     },
 32     "source": [
 33      "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/KnowledgeAgent_PraisonAI.ipynb)\n"
 34     ]
 35    },
 36    {
 37     "cell_type": "markdown",
 38     "id": "N4Vxz84co0Ac",
 39     "metadata": {
 40      "id": "N4Vxz84co0Ac"
 41     },
 42     "source": [
 43      "# Dependencies"
 44     ]
 45    },
 46    {
 47     "cell_type": "code",
 48     "execution_count": 1,
 49     "id": "1241a155",
 50     "metadata": {
 51      "colab": {
 52       "base_uri": "https://localhost:8080/"
 53      },
 54      "id": "1241a155",
 55      "outputId": "05e987e6-e332-42a6-af0e-109aed2d6016"
 56     },
 57     "outputs": [
 58      {
 59       "name": "stdout",
 60       "output_type": "stream",
 61       "text": [
 62        "\u001b[?25l   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m0.0/175.6 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
 63        "\u001b[2K   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m175.6/175.6 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
 64        "\u001b[?25h\u001b[?25l   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m0.0/130.2 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
 65        "\u001b[2K   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m11.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
 66        "\u001b[?25h\u001b[?25l   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m0.0/103.8 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
 67        "\u001b[2K   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m103.8/103.8 kB\u001b[0m \u001b[31m9.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
 68        "\u001b[?25h\u001b[?25l   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m0.0/44.4 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
 69        "\u001b[2K   \u001b[90mโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\u001b[0m \u001b[32m44.4/44.4 kB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
 70        "\u001b[?25h"
 71       ]
 72      }
 73     ],
 74     "source": [
 75      "!pip install -q praisonaiagents"
 76     ]
 77    },
 78    {
 79     "cell_type": "markdown",
 80     "id": "258c378c",
 81     "metadata": {
 82      "id": "258c378c"
 83     },
 84     "source": [
 85      "\n",
 86      "## ๐Ÿ”ง Tools Used\n",
 87      "- [PraisonAI](https://github.com/MervinPraison/PraisonAI): Multi-agent framework for LLMs  \n",
 88      "- OpenAI API: Used as the backend model (you'll need an API key)  \n",
 89      "- Built-in vector store for document retrieval (RAG)  \n"
 90     ]
 91    },
 92    {
 93     "cell_type": "markdown",
 94     "id": "26723867",
 95     "metadata": {
 96      "id": "26723867"
 97     },
 98     "source": [
 99      "\n",
100      "## ๐Ÿงพ YAML Prompt (Equivalent in Python)\n",
101      "The agent will:\n",
102      "- Be called `KnowledgeAgent`\n",
103      "- Analyze documents or topics\n",
104      "- Summarize findings in structured format\n"
105     ]
106    },
107    {
108     "cell_type": "markdown",
109     "id": "vDnilJPOo3Q4",
110     "metadata": {
111      "id": "vDnilJPOo3Q4"
112     },
113     "source": [
114      "# Setting Up Your OpenAI API Key"
115     ]
116    },
117    {
118     "cell_type": "code",
119     "execution_count": null,
120     "id": "7K3qo_5WocdJ",
121     "metadata": {
122      "id": "7K3qo_5WocdJ"
123     },
124     "outputs": [],
125     "source": [
126      "import os\n",
127      "from getpass import getpass\n",
128      "\n",
129      "os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: your api key here\")"
130     ]
131    },
132    {
133     "cell_type": "markdown",
134     "id": "8MssHldCpCK4",
135     "metadata": {
136      "id": "8MssHldCpCK4"
137     },
138     "source": [
139      "# Main"
140     ]
141    },
142    {
143     "cell_type": "code",
144     "execution_count": 4,
145     "id": "55d0c5f1",
146     "metadata": {
147      "colab": {
148       "base_uri": "https://localhost:8080/",
149       "height": 877,
150       "referenced_widgets": [
151        "3e9d882fec5947bb86b8aa237e498673",
152        "8cd0e464954d433b854f6f743e1016ae"
153       ]
154      },
155      "id": "55d0c5f1",
156      "outputId": "795d2f18-edfc-4c53-ac61-c420d0b660d4"
157     },
158     "outputs": [
159      {
160       "data": {
161        "text/html": [
162         "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ•ญโ”€ </span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8; font-weight: bold\">Agent Info</span><span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\"> โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ</span>\n",
163         "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>                                                                                                                 <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>\n",
164         "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>  <span style=\"color: #ff9b9b; text-decoration-color: #ff9b9b; font-weight: bold\">๐Ÿ‘ค Agent:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">KnowledgeAgent</span>                                                                                       <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>\n",
165         "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>  <span style=\"color: #b4b4b3; text-decoration-color: #b4b4b3; font-weight: bold\">Role:</span> <span style=\"color: #ffe5e5; text-decoration-color: #ffe5e5\">Assistant</span>                                                                                                <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>\n",
166         "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>                                                                                                                 <span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ”‚</span>\n",
167         "<span style=\"color: #d2e3c8; text-decoration-color: #d2e3c8\">โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ</span>\n",
168         "</pre>\n"
169        ],
170        "text/plain": [
171         "\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",
172         "\u001b[38;2;210;227;200mโ”‚\u001b[0m                                                                                                                 \u001b[38;2;210;227;200mโ”‚\u001b[0m\n",
173         "\u001b[38;2;210;227;200mโ”‚\u001b[0m  \u001b[1;38;2;255;155;155m๐Ÿ‘ค Agent:\u001b[0m \u001b[38;2;255;229;229mKnowledgeAgent\u001b[0m                                                                                       \u001b[38;2;210;227;200mโ”‚\u001b[0m\n",
174         "\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",
175         "\u001b[38;2;210;227;200mโ”‚\u001b[0m                                                                                                                 \u001b[38;2;210;227;200mโ”‚\u001b[0m\n",
176         "\u001b[38;2;210;227;200mโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\u001b[0m\n"
177        ]
178       },
179       "metadata": {},
180       "output_type": "display_data"
181      },
182      {
183       "data": {
184        "application/vnd.jupyter.widget-view+json": {
185         "model_id": "3e9d882fec5947bb86b8aa237e498673",
186         "version_major": 2,
187         "version_minor": 0
188        },
189        "text/plain": [
190         "Output()"
191        ]
192       },
193       "metadata": {},
194       "output_type": "display_data"
195      },
196      {
197       "data": {
198        "text/html": [
199         "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
200        ],
201        "text/plain": []
202       },
203       "metadata": {},
204       "output_type": "display_data"
205      },
206      {
207       "data": {
208        "text/html": [
209         "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
210         "</pre>\n"
211        ],
212        "text/plain": [
213         "\n"
214        ]
215       },
216       "metadata": {},
217       "output_type": "display_data"
218      },
219      {
220       "data": {
221        "text/html": [
222         "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">Response generated in 7.9s</span>\n",
223         "</pre>\n"
224        ],
225        "text/plain": [
226         "\u001b[2mResponse generated in 7.9s\u001b[0m\n"
227        ]
228       },
229       "metadata": {},
230       "output_type": "display_data"
231      },
232      {
233       "data": {
234        "text/html": [
235         "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Task โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ</span>\n",
236         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> You need to do the following task: Analyze a topic and produce a structured summary. Expected Output: A         <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
237         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> well-structured paragraph or bullet summary. Please provide only the final result of your work. Do not add any  <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
238         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> conversation or extra explanation.                                                                              <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
239         "<span style=\"color: #008080; text-decoration-color: #008080\">โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ</span>\n",
240         "</pre>\n"
241        ],
242        "text/plain": [
243         "\u001b[36mโ•ญโ”€\u001b[0m\u001b[36mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[36m Task \u001b[0m\u001b[36mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[36mโ”€โ•ฎ\u001b[0m\n",
244         "\u001b[36mโ”‚\u001b[0m You need to do the following task: Analyze a topic and produce a structured summary. Expected Output: A         \u001b[36mโ”‚\u001b[0m\n",
245         "\u001b[36mโ”‚\u001b[0m well-structured paragraph or bullet summary. Please provide only the final result of your work. Do not add any  \u001b[36mโ”‚\u001b[0m\n",
246         "\u001b[36mโ”‚\u001b[0m conversation or extra explanation.                                                                              \u001b[36mโ”‚\u001b[0m\n",
247         "\u001b[36mโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\u001b[0m\n"
248        ]
249       },
250       "metadata": {},
251       "output_type": "display_data"
252      },
253      {
254       "data": {
255        "text/html": [
256         "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Response โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ</span>\n",
257         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"font-weight: bold\">Topic: The Impact of Artificial Intelligence on Healthcare</span>                                                      <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
258         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>                                                                                                                 <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
259         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><span style=\"font-weight: bold\">Introduction</span>: Artificial Intelligence (AI) is revolutionizing the healthcare industry by enhancing           <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
260         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>diagnostic accuracy, personalizing treatment plans, and improving patient outcomes.                          <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
261         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><span style=\"font-weight: bold\">Diagnostic Improvements</span>: AI algorithms, particularly in imaging and pathology, can analyze medical data with <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
262         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>high precision, leading to early and accurate disease detection, such as in radiology for identifying tumors <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
263         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>or in dermatology for skin cancer detection.                                                                 <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
264         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><span style=\"font-weight: bold\">Personalized Medicine</span>: AI facilitates the development of personalized treatment plans by analyzing genetic   <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
265         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>information and predicting patient responses to various treatments, thus optimizing therapeutic efficacy and <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
266         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>minimizing adverse effects.                                                                                  <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
267         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><span style=\"font-weight: bold\">Operational Efficiency</span>: AI streamlines administrative tasks, such as scheduling, patient record management,  <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
268         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>and billing, reducing the burden on healthcare professionals and allowing them to focus more on patient      <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
269         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>care.                                                                                                        <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
270         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><span style=\"font-weight: bold\">Predictive Analytics</span>: AI models can predict patient admission rates, potential outbreaks, and disease        <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
271         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>progression, enabling proactive healthcare management and resource allocation.                               <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
272         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><span style=\"font-weight: bold\">Challenges</span>: Despite its benefits, AI in healthcare faces challenges like data privacy concerns, the need for <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
273         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>large datasets for training, potential biases in AI algorithms, and the requirement for regulatory           <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
274         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>frameworks to ensure safety and efficacy.                                                                    <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
275         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> โ€ข </span><span style=\"font-weight: bold\">Future Prospects</span>: Continued advancements in AI technology promise further integration into healthcare,       <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
276         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>potentially leading to fully automated diagnostic systems and more sophisticated predictive models,          <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
277         "<span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">   </span>ultimately transforming patient care and healthcare delivery.                                                <span style=\"color: #008080; text-decoration-color: #008080\">โ”‚</span>\n",
278         "<span style=\"color: #008080; text-decoration-color: #008080\">โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ</span>\n",
279         "</pre>\n"
280        ],
281        "text/plain": [
282         "\u001b[36mโ•ญโ”€\u001b[0m\u001b[36mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[36m Response \u001b[0m\u001b[36mโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\u001b[0m\u001b[36mโ”€โ•ฎ\u001b[0m\n",
283         "\u001b[36mโ”‚\u001b[0m \u001b[1mTopic: The Impact of Artificial Intelligence on Healthcare\u001b[0m                                                      \u001b[36mโ”‚\u001b[0m\n",
284         "\u001b[36mโ”‚\u001b[0m                                                                                                                 \u001b[36mโ”‚\u001b[0m\n",
285         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m โ€ข \u001b[0m\u001b[1mIntroduction\u001b[0m: Artificial Intelligence (AI) is revolutionizing the healthcare industry by enhancing           \u001b[36mโ”‚\u001b[0m\n",
286         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mdiagnostic accuracy, personalizing treatment plans, and improving patient outcomes.                          \u001b[36mโ”‚\u001b[0m\n",
287         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m โ€ข \u001b[0m\u001b[1mDiagnostic Improvements\u001b[0m: AI algorithms, particularly in imaging and pathology, can analyze medical data with \u001b[36mโ”‚\u001b[0m\n",
288         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mhigh precision, leading to early and accurate disease detection, such as in radiology for identifying tumors \u001b[36mโ”‚\u001b[0m\n",
289         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mor in dermatology for skin cancer detection.                                                                 \u001b[36mโ”‚\u001b[0m\n",
290         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m โ€ข \u001b[0m\u001b[1mPersonalized Medicine\u001b[0m: AI facilitates the development of personalized treatment plans by analyzing genetic   \u001b[36mโ”‚\u001b[0m\n",
291         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0minformation and predicting patient responses to various treatments, thus optimizing therapeutic efficacy and \u001b[36mโ”‚\u001b[0m\n",
292         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mminimizing adverse effects.                                                                                  \u001b[36mโ”‚\u001b[0m\n",
293         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m โ€ข \u001b[0m\u001b[1mOperational Efficiency\u001b[0m: AI streamlines administrative tasks, such as scheduling, patient record management,  \u001b[36mโ”‚\u001b[0m\n",
294         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mand billing, reducing the burden on healthcare professionals and allowing them to focus more on patient      \u001b[36mโ”‚\u001b[0m\n",
295         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mcare.                                                                                                        \u001b[36mโ”‚\u001b[0m\n",
296         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m โ€ข \u001b[0m\u001b[1mPredictive Analytics\u001b[0m: AI models can predict patient admission rates, potential outbreaks, and disease        \u001b[36mโ”‚\u001b[0m\n",
297         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mprogression, enabling proactive healthcare management and resource allocation.                               \u001b[36mโ”‚\u001b[0m\n",
298         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m โ€ข \u001b[0m\u001b[1mChallenges\u001b[0m: Despite its benefits, AI in healthcare faces challenges like data privacy concerns, the need for \u001b[36mโ”‚\u001b[0m\n",
299         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mlarge datasets for training, potential biases in AI algorithms, and the requirement for regulatory           \u001b[36mโ”‚\u001b[0m\n",
300         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mframeworks to ensure safety and efficacy.                                                                    \u001b[36mโ”‚\u001b[0m\n",
301         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m โ€ข \u001b[0m\u001b[1mFuture Prospects\u001b[0m: Continued advancements in AI technology promise further integration into healthcare,       \u001b[36mโ”‚\u001b[0m\n",
302         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0mpotentially leading to fully automated diagnostic systems and more sophisticated predictive models,          \u001b[36mโ”‚\u001b[0m\n",
303         "\u001b[36mโ”‚\u001b[0m \u001b[1;33m   \u001b[0multimately transforming patient care and healthcare delivery.                                                \u001b[36mโ”‚\u001b[0m\n",
304         "\u001b[36mโ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\u001b[0m\n"
305        ]
306       },
307       "metadata": {},
308       "output_type": "display_data"
309      },
310      {
311       "name": "stdout",
312       "output_type": "stream",
313       "text": [
314        "๐Ÿ“„ Output Summary:\n",
315        "**Topic: The Impact of Artificial Intelligence on Healthcare**\n",
316        "\n",
317        "- **Introduction**: Artificial Intelligence (AI) is revolutionizing the healthcare industry by enhancing diagnostic accuracy, personalizing treatment plans, and improving patient outcomes.\n",
318        "  \n",
319        "- **Diagnostic Improvements**: AI algorithms, particularly in imaging and pathology, can analyze medical data with high precision, leading to early and accurate disease detection, such as in radiology for identifying tumors or in dermatology for skin cancer detection.\n",
320        "\n",
321        "- **Personalized Medicine**: AI facilitates the development of personalized treatment plans by analyzing genetic information and predicting patient responses to various treatments, thus optimizing therapeutic efficacy and minimizing adverse effects.\n",
322        "\n",
323        "- **Operational Efficiency**: AI streamlines administrative tasks, such as scheduling, patient record management, and billing, reducing the burden on healthcare professionals and allowing them to focus more on patient care.\n",
324        "\n",
325        "- **Predictive Analytics**: AI models can predict patient admission rates, potential outbreaks, and disease progression, enabling proactive healthcare management and resource allocation.\n",
326        "\n",
327        "- **Challenges**: Despite its benefits, AI in healthcare faces challenges like data privacy concerns, the need for large datasets for training, potential biases in AI algorithms, and the requirement for regulatory frameworks to ensure safety and efficacy.\n",
328        "\n",
329        "- **Future Prospects**: Continued advancements in AI technology promise further integration into healthcare, potentially leading to fully automated diagnostic systems and more sophisticated predictive models, ultimately transforming patient care and healthcare delivery.\n"
330       ]
331      }
332     ],
333     "source": [
334      "\n",
335      "from praisonaiagents import Agent, Task, PraisonAIAgents\n",
336      "import os\n",
337      "\n",
338      "# ๐Ÿ”‘ Set your OpenAI API key\n",
339      "os.environ[\"OPENAI_API_KEY\"] = \"YOUR_API_KEY\"\n",
340      "# Define agent\n",
341      "knowledge_agent = Agent(\n",
342      "    name=\"KnowledgeAgent\",\n",
343      "    instructions=\"You are a knowledge expert. Research the given topic and summarize it clearly and concisely.\"\n",
344      ")\n",
345      "\n",
346      "# Define task\n",
347      "knowledge_task = Task(\n",
348      "    name=\"SummarizationTask\",\n",
349      "    description=\"Analyze a topic and produce a structured summary\",\n",
350      "    expected_output=\"A well-structured paragraph or bullet summary\",\n",
351      "    agent=knowledge_agent\n",
352      ")\n",
353      "\n",
354      "# Build system\n",
355      "agents = PraisonAIAgents(\n",
356      "    agents=[knowledge_agent],\n",
357      "    tasks=[knowledge_task],\n",
358      "    process=\"sequential\"\n",
359      ")\n",
360      "\n",
361      "# Run the system\n",
362      "result = agents.start(input=\"Explain how quantum computing differs from classical computing.\")\n",
363      "print(\"๐Ÿ“„ Output Summary:\")\n",
364      "print(result)\n"
365     ]
366    },
367    {
368     "cell_type": "markdown",
369     "id": "910d0f04",
370     "metadata": {
371      "id": "910d0f04"
372     },
373     "source": [
374      "\n",
375      "## ๐Ÿ“„ Output\n",
376      "The output will be a structured summary of the input topic (in this case: **quantum vs classical computing**).  \n",
377      "If the model cannot run due to Colab limits, a text description will be printed instead.\n"
378     ]
379    }
380   ],
381   "metadata": {
382    "colab": {
383     "provenance": []
384    },
385    "kernelspec": {
386     "display_name": "Python 3",
387     "name": "python3"
388    },
389    "language_info": {
390     "name": "python"
391    }
392   },
393   "nbformat": 4,
394   "nbformat_minor": 5
395  }