From ef053c6d9535d1c5f5910de543c783546cfeab3a Mon Sep 17 00:00:00 2001 From: DhivyaBharathy <157012713+Dhivya-Bharathy@users.noreply.github.com> Date: Wed, 25 Jun 2025 14:18:58 +0530 Subject: [PATCH 1/7] Add files via upload --- .../Chile_Government_Services_Assistant.ipynb | 300 ++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 examples/cookbooks/Chile_Government_Services_Assistant.ipynb diff --git a/examples/cookbooks/Chile_Government_Services_Assistant.ipynb b/examples/cookbooks/Chile_Government_Services_Assistant.ipynb new file mode 100644 index 00000000..774394e6 --- /dev/null +++ b/examples/cookbooks/Chile_Government_Services_Assistant.ipynb @@ -0,0 +1,300 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "ZH_nR-SvvkDG" + }, + "source": [ + "# Chile Government Services Assistant - AI Chatbot" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "w8B741JgvpFj" + }, + "source": [ + "This notebook demonstrates how to use an AI-powered assistant to answer questions about Chilean government services and procedures, using the Firecrawl API and a friendly, step-by-step conversational approach." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "y8jiJYf4FA0m" + }, + "source": [ + "[![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/Chile_Government_Services_Assistant.ipynb)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "RRw8sPG89KNb" + }, + "source": [ + "# Install dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "rW8ltqCICV8o" + }, + "outputs": [], + "source": [ + "!pip install flask firecrawl praisonaiagents google-genai python-dotenv deep-translator" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XGjyt-B_EfbM" + }, + "source": [ + "# Set API Keys" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "qf8B_YltDiIe" + }, + "outputs": [], + "source": [ + "import os\n", + "\n", + "os.environ['FIRECRAWL_API_KEY'] = \"your api key here\"\n", + "os.environ['OPENAI_API_KEY'] = \"your api key here\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ccO0vwvCEqUJ" + }, + "source": [ + "# Import Libraries & Translator" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "0prDQ5TpDnFu" + }, + "outputs": [], + "source": [ + "from firecrawl import FirecrawlApp, ScrapeOptions\n", + "from deep_translator import GoogleTranslator\n", + "import re\n", + "\n", + "def translate_to_spanish(text):\n", + " try:\n", + " return GoogleTranslator(source='auto', target='es').translate(text)\n", + " except Exception as e:\n", + " print(\"Translation to Spanish failed:\", e)\n", + " return text\n", + "\n", + "def translate_to_english(text):\n", + " try:\n", + " # Remove Markdown images and None values before translation\n", + " text = str(text).replace(\"None\", \"\")\n", + " text = re.sub(r'!\\[.*?\\]\\(.*?\\)', '', text)\n", + " return GoogleTranslator(source='auto', target='en').translate(text)\n", + " except Exception as e:\n", + " print(\"Translation to English failed:\", e)\n", + " return text" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WxOlCHMmEuK2" + }, + "source": [ + "# Firecrawl Tool Class" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "G4RyzJ5mDp0t" + }, + "outputs": [], + "source": [ + "class FirecrawlTool:\n", + " def __init__(self, api_key, instruction: str, template: str):\n", + " if not api_key:\n", + " raise ValueError(\"Firecrawl API key not provided.\")\n", + " self.app = FirecrawlApp(api_key=api_key)\n", + " self.instruction = instruction\n", + " self.template = template\n", + "\n", + " def search(self, search: str) -> str:\n", + " if not search or len(search) < 5:\n", + " return \"Error: Please provide a valid search query (at least 5 characters).\"\n", + " response_md = \"\"\n", + " try:\n", + " search_result = self.app.search(\n", + " query=self.instruction + search,\n", + " limit=2,\n", + " country=\"cl\",\n", + " lang=\"es\", # Always search in Spanish for best results\n", + " scrape_options=ScrapeOptions(formats=[\"markdown\", \"links\"])\n", + " )\n", + " if search_result and hasattr(search_result, 'data') and search_result.data:\n", + " filtered_results = [\n", + " result for result in search_result.data\n", + " if str(result.get(\"url\", \"\")).startswith(\"https://www.chileatiende.gob.cl/fichas\") and not str(result.get(\"url\", \"\")).endswith(\"pdf\")\n", + " ]\n", + " if filtered_results:\n", + " for num, result in enumerate(filtered_results, start=1):\n", + " response_md += self.template.format(\n", + " result_number=num,\n", + " page_title=str(result.get(\"title\", \"\")),\n", + " page_url=str(result.get(\"url\", \"\")),\n", + " page_content=str(result.get(\"markdown\", \"\"))\n", + " )\n", + " return response_md\n", + " else:\n", + " return None\n", + " else:\n", + " return None\n", + " except Exception as e:\n", + " return f\"Error during search: {e}\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "MjkjTWn_ExS0" + }, + "source": [ + "# Firecrawl Prompt Template" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "AfivymU8Dufz" + }, + "outputs": [], + "source": [ + "FIRECRAWL_INSTRUCTION = \"ChileAtiende: \"\n", + "FIRECRAWL_TEMPLATE = \"\"\"\n", + "# Result {result_number}\n", + "\n", + "## Page Name:\n", + "\"{page_title}\"\n", + "\n", + "## URL:\n", + "{page_url}\n", + "\n", + "## Content:\n", + "{page_content}\n", + "\n", + "\"\"\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "zK8AA_DlEz9K" + }, + "source": [ + "# Initialize Firecrawl Tool" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "c3NKK0ZjDwKT" + }, + "outputs": [], + "source": [ + "firecrawl_tool = FirecrawlTool(\n", + " api_key=os.environ['FIRECRAWL_API_KEY'],\n", + " instruction=FIRECRAWL_INSTRUCTION,\n", + " template=FIRECRAWL_TEMPLATE\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "uzXYIF_gE3XV" + }, + "source": [ + "# Main Chat Loop" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "TXMgZQNkDx7n", + "outputId": "76303cd1-a576-483f-a22d-9857e5e6d797" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello! I am your ChileAtiende assistant, Tomás. How can I help you today?\n", + "You can ask me, for example: How to renew your ID card, How to apply for the Winter Bonus, etc.\n", + "\n", + "You: exit\n", + "Tomás: It was a pleasure to help you. Goodbye!\n" + ] + } + ], + "source": [ + "print(\"Hello! I am your ChileAtiende assistant, Tomás. How can I help you today?\")\n", + "print(\"You can ask me, for example: How to renew your ID card, How to apply for the Winter Bonus, etc.\")\n", + "\n", + "while True:\n", + " user_input = input(\"\\nYou: \")\n", + " if user_input.lower() in [\"exit\", \"quit\"]:\n", + " print(\"Tomás: It was a pleasure to help you. Goodbye!\")\n", + " break\n", + "\n", + " # Translate English input to Spanish for Firecrawl\n", + " spanish_query = translate_to_spanish(user_input)\n", + " spanish_answer = firecrawl_tool.search(spanish_query)\n", + "\n", + " # Only translate if we got a real answer\n", + " if spanish_answer and isinstance(spanish_answer, str) and spanish_answer.strip() and \"Error\" not in spanish_answer:\n", + " try:\n", + " english_answer = translate_to_english(spanish_answer)\n", + " print(\"\\nTomás (in English):\\n\", english_answer)\n", + " except Exception as e:\n", + " print(f\"\\nTomás: I found information, but couldn't translate it. Here it is in Spanish:\\n{spanish_answer}\\n(Translation error: {e})\")\n", + " else:\n", + " print(\"\\nTomás: Sorry, I couldn't find relevant information. Try rephrasing your question or ask about another service.\")" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From f514bf254bb445b617d135353665df48b29384ea Mon Sep 17 00:00:00 2001 From: DhivyaBharathy <157012713+Dhivya-Bharathy@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:25:05 +0530 Subject: [PATCH 2/7] Add files via upload --- .../Pocky_Cybersecurity_PoC_Agent.ipynb | 233 ++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb diff --git a/examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb b/examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb new file mode 100644 index 00000000..35b9642a --- /dev/null +++ b/examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb @@ -0,0 +1,233 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Pocky Query Tool: Automated CVE PoC Search & Validation\n", + "\n", + "A lightweight, web-scale agent that helps you find, filter, and fetch real-world PoC exploits — so you don't have to.\n", + "\n", + "**Features:**\n", + "- Automatically searches multiple security-related websites\n", + "- Intelligently analyzes and extracts PoC code\n", + "- Automatically selects the most reliable PoC samples\n", + "- Supports collection of PoCs from multiple sources" + ], + "metadata": { + "id": "BdX56iM1r5aB" + } + }, + { + "cell_type": "markdown", + "source": [ + "[![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/Pocky_Cybersecurity_PoC_Agent.ipynb)\n" + ], + "metadata": { + "id": "VW766102tUUY" + } + }, + { + "cell_type": "markdown", + "source": [ + "# Install Dependencies" + ], + "metadata": { + "id": "cBu2iXmJsVqE" + } + }, + { + "cell_type": "code", + "source": [ + "!pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4" + ], + "metadata": { + "id": "VvbA3A7XsTFm" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Set API Keys" + ], + "metadata": { + "id": "Q6B2VEkFsB32" + } + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "\n", + "# Set your API keys here (replace with your actual keys)\n", + "os.environ[\"EXA_API_KEY\"] = \"your api key\"\n", + "os.environ[\"OPENAI_API_KEY\"] = \"your api key\"\n", + "os.environ[\"OPENAI_BASE_URL\"] = \"https://api.openai.com/v1\" # Optional, for custom OpenAI endpoints" + ], + "metadata": { + "id": "OlOI3yc_sAkN" + }, + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Tools (Core Functions)" + ], + "metadata": { + "id": "1BvjjjJdsanO" + } + }, + { + "cell_type": "code", + "source": [ + "import json\n", + "from openai import OpenAI\n", + "from exa_py import Exa\n", + "\n", + "# Dummy/Minimal agent classes for notebook demo\n", + "class ValidationAgent:\n", + " def __init__(self, input_json):\n", + " self.input_json = input_json\n", + " def run(self):\n", + " # Dummy validation logic for notebook demo\n", + " data = json.loads(self.input_json)\n", + " return True if \"attack_intent\" in data and \"poc_sample\" in data else False\n", + "\n", + "class AttackIntentAgent:\n", + " def __init__(self, description):\n", + " self.description = description\n", + " def run(self):\n", + " # Dummy intent extraction for notebook demo\n", + " return f\"Intent for: {self.description[:50]}...\"" + ], + "metadata": { + "id": "GYfAJLXOsbga" + }, + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## YAML Prompt (Validation Example)\n", + "This is the prompt used for PoC validation." + ], + "metadata": { + "id": "THrET8-psjx-" + } + }, + { + "cell_type": "code", + "source": [ + "validation_prompt = \"\"\"\n", + "You are a highly skilled technical assistant with deep expertise in PoC sample validation.\n", + "\n", + "Given the attack intent of a CVE vulnerability and a PoC sample gathered from public sources, your task is to analyze whether the PoC correctly implements the intended attack behavior.\n", + "\n", + "Specifically:\n", + "- Understand the CVE's attack intent, including the attack goal and the underlying exploitation mechanism.\n", + "- Analyze the PoC to determine whether it is designed to achieve this intent.\n", + "- Check whether the payloads, request structures, and overall logic of the PoC align with the described attack intent.\n", + "- You do not need to execute the PoC. Focus on static validation through reasoning and consistency.\n", + "\n", + "Your output must be a JSON object with two fields:\n", + "- \"valid\": a boolean indicating whether the PoC correctly reflects the attack intent.\n", + "- \"reasoning\": a brief explanation of your judgment. If \"valid\" is false, the reasoning must clearly explain what is incorrect or inconsistent in the PoC compared to the attack intent, so that the PoC can be revised accordingly.\n", + "\"\"\"\n", + "print(validation_prompt)" + ], + "metadata": { + "id": "9q3aKl1xshrb" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Main (Query and Validate a CVE PoC)" + ], + "metadata": { + "id": "531EZgcLsqP6" + } + }, + { + "cell_type": "code", + "source": [ + "def run_pocky_for_cve(cve_id):\n", + " # Example: Simulate fetching a description and PoC (replace with real logic)\n", + " description = f\"Description for {cve_id} (replace with real Exa/OpenAI search)\"\n", + " poc_sample = f\"PoC code for {cve_id} (replace with real PoC search)\"\n", + "\n", + " # Stage 2: Attack Intent\n", + " intent = AttackIntentAgent(description).run()\n", + " print(f\"Attack Intent: {intent}\")\n", + "\n", + " # Stage 3: Validation\n", + " validation_input = json.dumps({\"attack_intent\": intent, \"poc_sample\": poc_sample}, indent=2)\n", + " valid = ValidationAgent(validation_input).run()\n", + " print(f\"Validation Result: {valid}\")\n", + " if valid:\n", + " print(f\"PoC for {cve_id} is valid and ready to use.\")\n", + " else:\n", + " print(f\"PoC for {cve_id} failed validation.\")" + ], + "metadata": { + "id": "PQvtF-RqsrP6" + }, + "execution_count": 5, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# Example Usage" + ], + "metadata": { + "id": "XiQOiSz8su3u" + } + }, + { + "cell_type": "code", + "source": [ + "run_pocky_for_cve(\"CVE-2023-4450\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "39w-qpecswjw", + "outputId": "cdcb3b29-7338-4e3e-b160-5f9568c194ca" + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Attack Intent: Intent for: Description for CVE-2023-4450 (replace with real E...\n", + "Validation Result: True\n", + "PoC for CVE-2023-4450 is valid and ready to use.\n" + ] + } + ] + } + ] +} \ No newline at end of file From 95f0b4df38a09eb09e386eec4cc7104b5c6dffb8 Mon Sep 17 00:00:00 2001 From: DhivyaBharathy <157012713+Dhivya-Bharathy@users.noreply.github.com> Date: Wed, 25 Jun 2025 19:04:52 +0530 Subject: [PATCH 3/7] Add files via upload --- examples/cookbooks/LegaliaAI_MiniCourt.ipynb | 1614 ++++++++++++++++++ 1 file changed, 1614 insertions(+) create mode 100644 examples/cookbooks/LegaliaAI_MiniCourt.ipynb diff --git a/examples/cookbooks/LegaliaAI_MiniCourt.ipynb b/examples/cookbooks/LegaliaAI_MiniCourt.ipynb new file mode 100644 index 00000000..09643ea8 --- /dev/null +++ b/examples/cookbooks/LegaliaAI_MiniCourt.ipynb @@ -0,0 +1,1614 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "4c03cd7e", + "metadata": { + "id": "4c03cd7e" + }, + "source": [ + "# ⚖️ Legalia AI - Mini Court Simulation\n", + "\n", + "A simplified court case simulation with essential AI agents." + ] + }, + { + "cell_type": "markdown", + "source": [ + "[![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/LegaliaAI_MiniCourt.ipynb)\n" + ], + "metadata": { + "id": "k0GmORjCRMGL" + }, + "id": "k0GmORjCRMGL" + }, + { + "cell_type": "markdown", + "id": "98fc3316", + "metadata": { + "id": "98fc3316" + }, + "source": [ + "## Install Dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bb57c529", + "metadata": { + "id": "bb57c529" + }, + "outputs": [], + "source": [ + "!pip install praisonaiagents openai python-dotenv" + ] + }, + { + "cell_type": "markdown", + "id": "cfdb1a0c", + "metadata": { + "id": "cfdb1a0c" + }, + "source": [ + "## Import Libraries & Setup" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "f7c5e0a6", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "f7c5e0a6", + "outputId": "20b3baf7-6099-4c35-8ec8-9d5659553c30" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "✅ Setup complete!\n" + ] + } + ], + "source": [ + "import os\n", + "from dotenv import load_dotenv\n", + "from IPython.display import display, HTML\n", + "import time\n", + "\n", + "load_dotenv()\n", + "\n", + "# Setup API key\n", + "api_key = os.getenv('OPENAI_API_KEY')\n", + "if not api_key:\n", + " print(\"🔑 Enter your OpenAI API key:\")\n", + " api_key = input(\"API Key: \").strip()\n", + " os.environ['OPENAI_API_KEY'] = \"Enter your api key\"\n", + "\n", + "print(\"✅ Setup complete!\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "b6c7c2f3", + "metadata": { + "id": "b6c7c2f3" + }, + "source": [ + "## Create Mini Agents" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "6d7a8426", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "6d7a8426", + "outputId": "7851dfcc-14e1-4714-fc84-f26289d87dcf" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "✅ Mini agents created!\n" + ] + } + ], + "source": [ + "from praisonaiagents import Agent\n", + "\n", + "# Judge Agent\n", + "judge = Agent(\n", + " name=\"Judge\",\n", + " role=\"Preside over court proceedings\",\n", + " llm=\"gpt-4o-mini\",\n", + " instructions=[\n", + " \"You are an impartial judge\",\n", + " \"Make fair decisions based on evidence\",\n", + " \"Keep responses under 100 words\"\n", + " ],\n", + " markdown=True\n", + ")\n", + "\n", + "# Prosecutor Agent\n", + "prosecutor = Agent(\n", + " name=\"Prosecutor\",\n", + " role=\"Present case against defendant\",\n", + " llm=\"gpt-4o-mini\",\n", + " instructions=[\n", + " \"You are a prosecutor seeking conviction\",\n", + " \"Present evidence methodically\",\n", + " \"Keep responses under 80 words\"\n", + " ],\n", + " markdown=True\n", + ")\n", + "\n", + "# Defense Agent\n", + "defense = Agent(\n", + " name=\"Defense\",\n", + " role=\"Defend the accused\",\n", + " llm=\"gpt-4o-mini\",\n", + " instructions=[\n", + " \"You are a defense attorney\",\n", + " \"Create reasonable doubt\",\n", + " \"Keep responses under 80 words\"\n", + " ],\n", + " markdown=True\n", + ")\n", + "\n", + "# Witness Agent\n", + "witness = Agent(\n", + " name=\"Witness\",\n", + " role=\"Provide testimony\",\n", + " llm=\"gpt-4o-mini\",\n", + " instructions=[\n", + " \"You are a witness testifying\",\n", + " \"Provide factual testimony\",\n", + " \"Keep responses under 60 words\"\n", + " ],\n", + " markdown=True\n", + ")\n", + "\n", + "print(\"✅ Mini agents created!\")\n" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Case Details Input" + ], + "metadata": { + "id": "eMSO8H5jQx5O" + }, + "id": "eMSO8H5jQx5O" + }, + { + "cell_type": "code", + "source": [ + "# Simple case details\n", + "case_title = input(\"Case Title (e.g., 'State vs. Smith'): \") or \"State vs. Smith\"\n", + "case_description = input(\"Case Description: \") or \"Theft case involving stolen laptop\"\n", + "evidence = input(\"Key Evidence: \") or \"Security camera footage and witness testimony\"\n", + "\n", + "print(f\"\\n📋 Case: {case_title}\")\n", + "print(f\"📝 Description: {case_description}\")\n", + "print(f\"🔍 Evidence: {evidence}\")\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "fAIzu_3vPaHJ", + "outputId": "1df808db-e911-4e9f-ccf4-8c101040f89a" + }, + "id": "fAIzu_3vPaHJ", + "execution_count": 15, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Case Title (e.g., 'State vs. Smith'): Doe vs. Wilson\n", + "Case Description: The plaintiff claims to have suffered emotional distress due to repeated online harassment\n", + "Key Evidence: Screenshots of messages, social media posts, therapist’s report\n", + "\n", + "📋 Case: Doe vs. Wilson\n", + "📝 Description: The plaintiff claims to have suffered emotional distress due to repeated online harassment\n", + "🔍 Evidence: Screenshots of messages, social media posts, therapist’s report\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "id": "6e418e95", + "metadata": { + "id": "6e418e95" + }, + "source": [ + "# Helper Functions (Fixed with .start())## Cell 4: Case Details Input" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "fd9da25c", + "metadata": { + "id": "fd9da25c" + }, + "outputs": [], + "source": [ + "# Display function\n", + "def show_message(name, role, message, color=\"#4CAF50\"):\n", + " html = f\"\"\"\n", + "
\n", + " ⚖️ {name}{role}
\n", + "
{message}
\n", + "
\n", + " \"\"\"\n", + " display(HTML(html))\n", + "\n", + "# Run agent using .start()\n", + "def run_agent(agent, prompt, name, role, color=\"#4CAF50\"):\n", + " try:\n", + " response = agent.start(prompt)\n", + " show_message(name, role, response, color)\n", + " return response\n", + " except Exception as e:\n", + " show_message(\"System\", \"Error\", str(e), \"#f44336\")\n", + " return \"\"\n" + ] + }, + { + "cell_type": "markdown", + "id": "bb089a4e", + "metadata": { + "id": "bb089a4e" + }, + "source": [ + "## Mini Court Simulation" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "ade19755", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000, + "referenced_widgets": [ + "74964427de63470da100903aac0b8c78", + "45ff535d008a4b30b53a0e72edee016b", + "9e740fc3b45c454e96dfe29b4c0edb53", + "c04a2ce5fcc544d8ac72aa67776c0fd0", + "c0c194ce705f4418961c84f0bacb1acf", + "4ef74a10d03747608c9011027bfa877c", + "f4d166f4a67e41679066f05d4f224c31", + "f47eec09409e440091431311f3048518", + "801192cdda5e4736bc53dba478e1dcc1", + "1928c67194d4409a9528a796bbe1fce1" + ] + }, + "id": "ade19755", + "outputId": "b6259040-2eb5-4f10-c6ac-0795d19c889c" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "🚀 Starting Mini Court Simulation...\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "

📅 Day 1: Opening Statements

" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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;229mJudge\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;229mPreside over court proceedings\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" + ], + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+              "                                                                                                                 \n",
+              "  👤 Agent: Judge                                                                                                \n",
+              "  Role: Preside over court proceedings                                                                           \n",
+              "                                                                                                                 \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "74964427de63470da100903aac0b8c78" + } + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [], + "text/html": [ + "
\n"
+            ]
+          },
+          "metadata": {}
+        },
+        {
+          "output_type": "display_data",
+          "data": {
+            "text/plain": [
+              "\n"
+            ],
+            "text/html": [
+              "
\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "\u001b[2mResponse generated in 3.9s\u001b[0m\n" + ], + "text/html": [ + "
Response generated in 3.9s\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 You are Judge presiding over \"Doe vs. Wilson\". Open the court proceedings professionally. Case: The plaintiff \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m claims to have suffered emotional distress due to repeated online harassment Keep it brief and formal. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+              " You are Judge presiding over \"Doe vs. Wilson\". Open the court proceedings professionally. Case: The plaintiff   \n",
+              " claims to have suffered emotional distress due to repeated online harassment Keep it brief and formal.          \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 Court is now in session. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Case number 2023-001: Doe vs. Wilson. The plaintiff, Ms. Doe, alleges emotional distress resulting from \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m repeated online harassment by the defendant, Mr. Wilson. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Both parties will present their evidence and arguments. I remind all present to maintain decorum. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Let us proceed with the plaintiff's opening statement. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+              " Court is now in session.                                                                                        \n",
+              "                                                                                                                 \n",
+              " Case number 2023-001: Doe vs. Wilson. The plaintiff, Ms. Doe, alleges emotional distress resulting from         \n",
+              " repeated online harassment by the defendant, Mr. Wilson.                                                        \n",
+              "                                                                                                                 \n",
+              " Both parties will present their evidence and arguments. I remind all present to maintain decorum.               \n",
+              "                                                                                                                 \n",
+              " Let us proceed with the plaintiff's opening statement.                                                          \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "
\n", + " ⚖️ JudgePresiding Judge
\n", + "
Court is now in session. \n", + "\n", + "Case number 2023-001: Doe vs. Wilson. The plaintiff, Ms. Doe, alleges emotional distress resulting from repeated online harassment by the defendant, Mr. Wilson. \n", + "\n", + "Both parties will present their evidence and arguments. I remind all present to maintain decorum. \n", + "\n", + "Let us proceed with the plaintiff's opening statement.
\n", + "
\n", + " " + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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;229mProsecutor\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;229mPresent case against defendant\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" + ], + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+              "                                                                                                                 \n",
+              "  👤 Agent: Prosecutor                                                                                           \n",
+              "  Role: Present case against defendant                                                                           \n",
+              "                                                                                                                 \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "9e740fc3b45c454e96dfe29b4c0edb53" + } + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [], + "text/html": [ + "
\n"
+            ]
+          },
+          "metadata": {}
+        },
+        {
+          "output_type": "display_data",
+          "data": {
+            "text/plain": [
+              "\n"
+            ],
+            "text/html": [
+              "
\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "\u001b[2mResponse generated in 3.1s\u001b[0m\n" + ], + "text/html": [ + "
Response generated in 3.1s\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 You are the Prosecutor for \"Doe vs. Wilson\". Give your opening statement. Evidence: Screenshots of messages, \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m social media posts, therapist’s report Be confident and factual. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+              " You are the Prosecutor for \"Doe vs. Wilson\". Give your opening statement. Evidence: Screenshots of messages,    \n",
+              " social media posts, therapist’s report Be confident and factual.                                                \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 Ladies and gentlemen of the jury, today we present clear evidence against the defendant, Wilson. We will show \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m you screenshots of messages that reveal intent and motive, alongside social media posts that further \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m corroborate this behavior. Additionally, a therapist’s report will demonstrate the psychological impact on the \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m victim, Doe. This evidence will establish a pattern of harassment and intimidation. We ask you to consider the \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m facts carefully and deliver a just verdict. Thank you. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+              " Ladies and gentlemen of the jury, today we present clear evidence against the defendant, Wilson. We will show   \n",
+              " you screenshots of messages that reveal intent and motive, alongside social media posts that further            \n",
+              " corroborate this behavior. Additionally, a therapist’s report will demonstrate the psychological impact on the  \n",
+              " victim, Doe. This evidence will establish a pattern of harassment and intimidation. We ask you to consider the  \n",
+              " facts carefully and deliver a just verdict. Thank you.                                                          \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "
\n", + " ⚖️ ProsecutorState Attorney
\n", + "
Ladies and gentlemen of the jury, today we present clear evidence against the defendant, Wilson. We will show you screenshots of messages that reveal intent and motive, alongside social media posts that further corroborate this behavior. Additionally, a therapist’s report will demonstrate the psychological impact on the victim, Doe. This evidence will establish a pattern of harassment and intimidation. We ask you to consider the facts carefully and deliver a just verdict. Thank you.
\n", + "
\n", + " " + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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;229mDefense\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;229mDefend the accused\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" + ], + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+              "                                                                                                                 \n",
+              "  👤 Agent: Defense                                                                                              \n",
+              "  Role: Defend the accused                                                                                       \n",
+              "                                                                                                                 \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "c0c194ce705f4418961c84f0bacb1acf" + } + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [], + "text/html": [ + "
\n"
+            ]
+          },
+          "metadata": {}
+        },
+        {
+          "output_type": "display_data",
+          "data": {
+            "text/plain": [
+              "\n"
+            ],
+            "text/html": [
+              "
\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "\u001b[2mResponse generated in 3.3s\u001b[0m\n" + ], + "text/html": [ + "
Response generated in 3.3s\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 You are the Defense Attorney for \"Doe vs. Wilson\". Give your opening statement. Challenge the prosecution's \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m case. Emphasize presumption of innocence. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+              " You are the Defense Attorney for \"Doe vs. Wilson\". Give your opening statement. Challenge the prosecution's     \n",
+              " case. Emphasize presumption of innocence.                                                                       \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 Ladies and gentlemen of the jury, today you will hear the prosecution's case against my client, Mr. Wilson. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m However, I urge you to remember that the burden of proof lies with them. They must prove guilt beyond a \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m reasonable doubt. We will show that the evidence is circumstantial, unreliable, and lacks credibility. Mr. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Wilson is presumed innocent until proven guilty, and we will demonstrate that reasonable doubt exists in this \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m case. Thank you. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+              " Ladies and gentlemen of the jury, today you will hear the prosecution's case against my client, Mr. Wilson.     \n",
+              " However, I urge you to remember that the burden of proof lies with them. They must prove guilt beyond a         \n",
+              " reasonable doubt. We will show that the evidence is circumstantial, unreliable, and lacks credibility. Mr.      \n",
+              " Wilson is presumed innocent until proven guilty, and we will demonstrate that reasonable doubt exists in this   \n",
+              " case. Thank you.                                                                                                \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "
\n", + " ⚖️ DefenseDefense Attorney
\n", + "
Ladies and gentlemen of the jury, today you will hear the prosecution's case against my client, Mr. Wilson. However, I urge you to remember that the burden of proof lies with them. They must prove guilt beyond a reasonable doubt. We will show that the evidence is circumstantial, unreliable, and lacks credibility. Mr. Wilson is presumed innocent until proven guilty, and we will demonstrate that reasonable doubt exists in this case. Thank you.
\n", + "
\n", + " " + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "

📅 Day 2: Witness Testimony

" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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;229mWitness\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;229mProvide testimony\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" + ], + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+              "                                                                                                                 \n",
+              "  👤 Agent: Witness                                                                                              \n",
+              "  Role: Provide testimony                                                                                        \n",
+              "                                                                                                                 \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "f4d166f4a67e41679066f05d4f224c31" + } + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [], + "text/html": [ + "
\n"
+            ]
+          },
+          "metadata": {}
+        },
+        {
+          "output_type": "display_data",
+          "data": {
+            "text/plain": [
+              "\n"
+            ],
+            "text/html": [
+              "
\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "\u001b[2mResponse generated in 2.3s\u001b[0m\n" + ], + "text/html": [ + "
Response generated in 2.3s\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 You are a witness in \"Doe vs. Wilson\". Provide your testimony about what you saw. Evidence: Screenshots of \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m messages, social media posts, therapist’s report Be factual and clear. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+              " You are a witness in \"Doe vs. Wilson\". Provide your testimony about what you saw. Evidence: Screenshots of      \n",
+              " messages, social media posts, therapist’s report Be factual and clear.                                          \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 On March 15, 2023, I observed a series of messages exchanged between Doe and Wilson on social media, indicating \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m a heated argument. The screenshots show Wilson making threatening remarks. Additionally, the therapist's report \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m dated March 20, 2023, confirms Doe's emotional distress linked to these interactions. I can confirm the \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m authenticity of these documents. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+              " On March 15, 2023, I observed a series of messages exchanged between Doe and Wilson on social media, indicating \n",
+              " a heated argument. The screenshots show Wilson making threatening remarks. Additionally, the therapist's report \n",
+              " dated March 20, 2023, confirms Doe's emotional distress linked to these interactions. I can confirm the         \n",
+              " authenticity of these documents.                                                                                \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "
\n", + " ⚖️ WitnessCourt Witness
\n", + "
On March 15, 2023, I observed a series of messages exchanged between Doe and Wilson on social media, indicating a heated argument. The screenshots show Wilson making threatening remarks. Additionally, the therapist's report dated March 20, 2023, confirms Doe's emotional distress linked to these interactions. I can confirm the authenticity of these documents.
\n", + "
\n", + " " + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "

📅 Day 3: Final Verdict

" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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;229mJudge\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;229mPreside over court proceedings\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" + ], + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+              "                                                                                                                 \n",
+              "  👤 Agent: Judge                                                                                                \n",
+              "  Role: Preside over court proceedings                                                                           \n",
+              "                                                                                                                 \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "801192cdda5e4736bc53dba478e1dcc1" + } + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [], + "text/html": [ + "
\n"
+            ]
+          },
+          "metadata": {}
+        },
+        {
+          "output_type": "display_data",
+          "data": {
+            "text/plain": [
+              "\n"
+            ],
+            "text/html": [
+              "
\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "\u001b[2mResponse generated in 2.3s\u001b[0m\n" + ], + "text/html": [ + "
Response generated in 2.3s\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 You are Judge presiding over \"Doe vs. Wilson\". Deliver your final verdict. Consider all evidence: Screenshots \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m of messages, social media posts, therapist’s report Be fair and explain your reasoning. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+              " You are Judge presiding over \"Doe vs. Wilson\". Deliver your final verdict. Consider all evidence: Screenshots   \n",
+              " of messages, social media posts, therapist’s report Be fair and explain your reasoning.                         \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "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 After careful consideration of the evidence presented, including the screenshots of messages, social media \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m posts, and the therapist's report, I find that the plaintiff, Ms. Doe, has demonstrated a credible case of \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m emotional distress due to the defendant's actions. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m The evidence shows a pattern of harassment that has significantly impacted Ms. Doe's mental well-being. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Therefore, I rule in favor of the plaintiff. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m Mr. Wilson is ordered to cease all forms of contact with Ms. Doe and to pay damages for the emotional distress \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m caused. Court is adjourned. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ], + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+              " After careful consideration of the evidence presented, including the screenshots of messages, social media      \n",
+              " posts, and the therapist's report, I find that the plaintiff, Ms. Doe, has demonstrated a credible case of      \n",
+              " emotional distress due to the defendant's actions.                                                              \n",
+              "                                                                                                                 \n",
+              " The evidence shows a pattern of harassment that has significantly impacted Ms. Doe's mental well-being.         \n",
+              " Therefore, I rule in favor of the plaintiff.                                                                    \n",
+              "                                                                                                                 \n",
+              " Mr. Wilson is ordered to cease all forms of contact with Ms. Doe and to pay damages for the emotional distress  \n",
+              " caused. Court is adjourned.                                                                                     \n",
+              "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+              "
\n" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + "
\n", + " ⚖️ JudgeFinal Verdict
\n", + "
After careful consideration of the evidence presented, including the screenshots of messages, social media posts, and the therapist's report, I find that the plaintiff, Ms. Doe, has demonstrated a credible case of emotional distress due to the defendant's actions.\n", + "\n", + "The evidence shows a pattern of harassment that has significantly impacted Ms. Doe's mental well-being. Therefore, I rule in favor of the plaintiff. \n", + "\n", + "Mr. Wilson is ordered to cease all forms of contact with Ms. Doe and to pay damages for the emotional distress caused. Court is adjourned.
\n", + "
\n", + " " + ] + }, + "metadata": {} + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\n", + "✅ Mini court simulation completed!\n" + ] + } + ], + "source": [ + "# Mini court simulation\n", + "print(\"🚀 Starting Mini Court Simulation...\")\n", + "\n", + "# Day 1: Opening\n", + "display(HTML(f\"

📅 Day 1: Opening Statements

\"))\n", + "\n", + "# Judge opens court\n", + "judge_prompt = f\"\"\"\n", + "You are Judge presiding over \"{case_title}\".\n", + "Open the court proceedings professionally.\n", + "Case: {case_description}\n", + "Keep it brief and formal.\n", + "\"\"\"\n", + "judge_response = run_agent(judge, judge_prompt, \"Judge\", \"Presiding Judge\", \"#8B4513\")\n", + "\n", + "# Prosecutor opening\n", + "prosecutor_prompt = f\"\"\"\n", + "You are the Prosecutor for \"{case_title}\".\n", + "Give your opening statement.\n", + "Evidence: {evidence}\n", + "Be confident and factual.\n", + "\"\"\"\n", + "prosecutor_response = run_agent(prosecutor, prosecutor_prompt, \"Prosecutor\", \"State Attorney\", \"#d32f2f\")\n", + "\n", + "# Defense opening\n", + "defense_prompt = f\"\"\"\n", + "You are the Defense Attorney for \"{case_title}\".\n", + "Give your opening statement.\n", + "Challenge the prosecution's case.\n", + "Emphasize presumption of innocence.\n", + "\"\"\"\n", + "defense_response = run_agent(defense, defense_prompt, \"Defense\", \"Defense Attorney\", \"#1976d2\")\n", + "\n", + "time.sleep(1)\n", + "\n", + "# Day 2: Testimony\n", + "display(HTML(f\"

📅 Day 2: Witness Testimony

\"))\n", + "\n", + "# Witness testimony\n", + "witness_prompt = f\"\"\"\n", + "You are a witness in \"{case_title}\".\n", + "Provide your testimony about what you saw.\n", + "Evidence: {evidence}\n", + "Be factual and clear.\n", + "\"\"\"\n", + "witness_response = run_agent(witness, witness_prompt, \"Witness\", \"Court Witness\", \"#ff9800\")\n", + "\n", + "time.sleep(1)\n", + "\n", + "# Day 3: Verdict\n", + "display(HTML(f\"

📅 Day 3: Final Verdict

\"))\n", + "\n", + "# Judge's verdict\n", + "verdict_prompt = f\"\"\"\n", + "You are Judge presiding over \"{case_title}\".\n", + "Deliver your final verdict.\n", + "Consider all evidence: {evidence}\n", + "Be fair and explain your reasoning.\n", + "\"\"\"\n", + "verdict_response = run_agent(judge, verdict_prompt, \"Judge\", \"Final Verdict\", \"#8B4513\")\n", + "\n", + "print(\"\\n✅ Mini court simulation completed!\")\n" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Summary" + ], + "metadata": { + "id": "0hP6lxvCRI1m" + }, + "id": "0hP6lxvCRI1m" + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "3cc7570e", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "3cc7570e", + "outputId": "2960f533-2a08-45c9-8653-95817f61f6d8" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "🎯 Mini Legalia AI Complete!\n", + "\n", + "This simplified version demonstrates:\n", + "- 4 Essential Agents: Judge, Prosecutor, Defense, Witness\n", + "- 3-Day Trial: Opening, Testimony, Verdict\n", + "- Real-time Interaction: Each agent responds based on case context\n", + "- Easy Setup: Minimal dependencies and configuration\n", + "\n", + "Perfect for quick demonstrations and learning! ⚖️\n" + ] + } + ], + "source": [ + "print(\"🎯 Mini Legalia AI Complete!\")\n", + "print(\"\\nThis simplified version demonstrates:\")\n", + "print(\"- 4 Essential Agents: Judge, Prosecutor, Defense, Witness\")\n", + "print(\"- 3-Day Trial: Opening, Testimony, Verdict\")\n", + "print(\"- Real-time Interaction: Each agent responds based on case context\")\n", + "print(\"- Easy Setup: Minimal dependencies and configuration\")\n", + "print(\"\\nPerfect for quick demonstrations and learning! ⚖️\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.10" + }, + "colab": { + "provenance": [] + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "74964427de63470da100903aac0b8c78": { + "model_module": "@jupyter-widgets/output", + "model_name": "OutputModel", + "model_module_version": "1.0.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/output", + "_model_module_version": "1.0.0", + "_model_name": "OutputModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/output", + "_view_module_version": "1.0.0", + "_view_name": "OutputView", + "layout": "IPY_MODEL_45ff535d008a4b30b53a0e72edee016b", + "msg_id": "", + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": "\u001b[32m╭─\u001b[0m\u001b[32m─────────────────────────────────────────────\u001b[0m\u001b[32m Generating... 3.8s \u001b[0m\u001b[32m──────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n\u001b[32m│\u001b[0m Court is now in session. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m Case number 2023-001: Doe vs. Wilson. The plaintiff, Ms. Doe, alleges emotional distress resulting from \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m repeated online harassment by the defendant, Mr. Wilson. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m Both parties will present their evidence and arguments. I remind all present to maintain decorum. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m Let us proceed with the plaintiff's \u001b[32m│\u001b[0m\n\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "text/html": "
╭────────────────────────────────────────────── Generating... 3.8s ───────────────────────────────────────────────╮\n Court is now in session.                                                                                        \n                                                                                                                 \n Case number 2023-001: Doe vs. Wilson. The plaintiff, Ms. Doe, alleges emotional distress resulting from         \n repeated online harassment by the defendant, Mr. Wilson.                                                        \n                                                                                                                 \n Both parties will present their evidence and arguments. I remind all present to maintain decorum.               \n                                                                                                                 \n Let us proceed with the plaintiff's                                                                             \n╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n
\n" + }, + "metadata": {} + } + ] + } + }, + "45ff535d008a4b30b53a0e72edee016b": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "9e740fc3b45c454e96dfe29b4c0edb53": { + "model_module": "@jupyter-widgets/output", + "model_name": "OutputModel", + "model_module_version": "1.0.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/output", + "_model_module_version": "1.0.0", + "_model_name": "OutputModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/output", + "_view_module_version": "1.0.0", + "_view_name": "OutputView", + "layout": "IPY_MODEL_c04a2ce5fcc544d8ac72aa67776c0fd0", + "msg_id": "", + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": "\u001b[32m╭─\u001b[0m\u001b[32m─────────────────────────────────────────────\u001b[0m\u001b[32m Generating... 2.9s \u001b[0m\u001b[32m──────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n\u001b[32m│\u001b[0m Ladies and gentlemen of the jury, today we present clear evidence against the defendant, Wilson. We will show \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m you screenshots of messages that reveal intent and motive, alongside social media posts that further \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m corroborate this behavior. Additionally, a therapist’s report will demonstrate the psychological impact on the \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m victim, Doe. This evidence will establish a pattern of harassment and intimidation. We ask you to consider the \u001b[32m│\u001b[0m\n\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "text/html": "
╭────────────────────────────────────────────── Generating... 2.9s ───────────────────────────────────────────────╮\n Ladies and gentlemen of the jury, today we present clear evidence against the defendant, Wilson. We will show   \n you screenshots of messages that reveal intent and motive, alongside social media posts that further            \n corroborate this behavior. Additionally, a therapist’s report will demonstrate the psychological impact on the  \n victim, Doe. This evidence will establish a pattern of harassment and intimidation. We ask you to consider the  \n╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n
\n" + }, + "metadata": {} + } + ] + } + }, + "c04a2ce5fcc544d8ac72aa67776c0fd0": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "c0c194ce705f4418961c84f0bacb1acf": { + "model_module": "@jupyter-widgets/output", + "model_name": "OutputModel", + "model_module_version": "1.0.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/output", + "_model_module_version": "1.0.0", + "_model_name": "OutputModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/output", + "_view_module_version": "1.0.0", + "_view_name": "OutputView", + "layout": "IPY_MODEL_4ef74a10d03747608c9011027bfa877c", + "msg_id": "", + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": "\u001b[32m╭─\u001b[0m\u001b[32m─────────────────────────────────────────────\u001b[0m\u001b[32m Generating... 3.1s \u001b[0m\u001b[32m──────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n\u001b[32m│\u001b[0m Ladies and gentlemen of the jury, today you will hear the prosecution's case against my client, Mr. Wilson. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m However, I urge you to remember that the burden of proof lies with them. They must prove guilt beyond a \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m reasonable doubt. We will show that the evidence is circumstantial, unreliable, and lacks credibility. Mr. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m Wilson is presumed innocent until proven guilty, and we \u001b[32m│\u001b[0m\n\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "text/html": "
╭────────────────────────────────────────────── Generating... 3.1s ───────────────────────────────────────────────╮\n Ladies and gentlemen of the jury, today you will hear the prosecution's case against my client, Mr. Wilson.     \n However, I urge you to remember that the burden of proof lies with them. They must prove guilt beyond a         \n reasonable doubt. We will show that the evidence is circumstantial, unreliable, and lacks credibility. Mr.      \n Wilson is presumed innocent until proven guilty, and we                                                         \n╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n
\n" + }, + "metadata": {} + } + ] + } + }, + "4ef74a10d03747608c9011027bfa877c": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "f4d166f4a67e41679066f05d4f224c31": { + "model_module": "@jupyter-widgets/output", + "model_name": "OutputModel", + "model_module_version": "1.0.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/output", + "_model_module_version": "1.0.0", + "_model_name": "OutputModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/output", + "_view_module_version": "1.0.0", + "_view_name": "OutputView", + "layout": "IPY_MODEL_f47eec09409e440091431311f3048518", + "msg_id": "", + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": "\u001b[32m╭─\u001b[0m\u001b[32m─────────────────────────────────────────────\u001b[0m\u001b[32m Generating... 2.1s \u001b[0m\u001b[32m──────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n\u001b[32m│\u001b[0m On March 15, 2023, I observed a series of messages exchanged between Doe and Wilson on social media, indicating \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m a heated argument. The screenshots show Wilson making threatening remarks. Additionally, the therapist's report \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m dated March 20, 2023, confirms Doe's emotional distress linked to these \u001b[32m│\u001b[0m\n\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "text/html": "
╭────────────────────────────────────────────── Generating... 2.1s ───────────────────────────────────────────────╮\n On March 15, 2023, I observed a series of messages exchanged between Doe and Wilson on social media, indicating \n a heated argument. The screenshots show Wilson making threatening remarks. Additionally, the therapist's report \n dated March 20, 2023, confirms Doe's emotional distress linked to these                                         \n╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n
\n" + }, + "metadata": {} + } + ] + } + }, + "f47eec09409e440091431311f3048518": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "801192cdda5e4736bc53dba478e1dcc1": { + "model_module": "@jupyter-widgets/output", + "model_name": "OutputModel", + "model_module_version": "1.0.0", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/output", + "_model_module_version": "1.0.0", + "_model_name": "OutputModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/output", + "_view_module_version": "1.0.0", + "_view_name": "OutputView", + "layout": "IPY_MODEL_1928c67194d4409a9528a796bbe1fce1", + "msg_id": "", + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": "\u001b[32m╭─\u001b[0m\u001b[32m─────────────────────────────────────────────\u001b[0m\u001b[32m Generating... 2.1s \u001b[0m\u001b[32m──────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n\u001b[32m│\u001b[0m After careful consideration of the evidence presented, including the screenshots of messages, social media \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m posts, and the therapist's report, I find that the plaintiff, Ms. Doe, has demonstrated a credible case of \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m emotional distress due to the defendant's actions. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m The evidence shows a pattern of harassment that has significantly impacted Ms. Doe's mental well-being. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m Therefore, I rule in favor of the plaintiff. \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n\u001b[32m│\u001b[0m Mr. Wilson is ordered to cease all forms of contact with Ms. Doe and to pay damages \u001b[32m│\u001b[0m\n\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n", + "text/html": "
╭────────────────────────────────────────────── Generating... 2.1s ───────────────────────────────────────────────╮\n After careful consideration of the evidence presented, including the screenshots of messages, social media      \n posts, and the therapist's report, I find that the plaintiff, Ms. Doe, has demonstrated a credible case of      \n emotional distress due to the defendant's actions.                                                              \n                                                                                                                 \n The evidence shows a pattern of harassment that has significantly impacted Ms. Doe's mental well-being.         \n Therefore, I rule in favor of the plaintiff.                                                                    \n                                                                                                                 \n Mr. Wilson is ordered to cease all forms of contact with Ms. Doe and to pay damages                             \n╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n
\n" + }, + "metadata": {} + } + ] + } + }, + "1928c67194d4409a9528a796bbe1fce1": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "model_module_version": "1.2.0", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + } + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file From f8959777a23d3ec55620b300cd7da1be3d59891c Mon Sep 17 00:00:00 2001 From: DhivyaBharathy-web Date: Thu, 26 Jun 2025 09:56:03 +0000 Subject: [PATCH 4/7] Add MemoryPal_Search_Agent notebook --- .../cookbooks/MemoryPal_Search_Agent.ipynb | 499 ++++++++++++++++++ 1 file changed, 499 insertions(+) create mode 100644 examples/cookbooks/MemoryPal_Search_Agent.ipynb diff --git a/examples/cookbooks/MemoryPal_Search_Agent.ipynb b/examples/cookbooks/MemoryPal_Search_Agent.ipynb new file mode 100644 index 00000000..2aa12abf --- /dev/null +++ b/examples/cookbooks/MemoryPal_Search_Agent.ipynb @@ -0,0 +1,499 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "-j-8RaEinSgs" + }, + "source": [ + "# 🧠 MemoryPal (PraisonAI Edition)\n", + "\n", + "A minimal example of using PraisonAI's Agent with a custom internet search tool in Python, ready for Google Colab." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "tztyseN5pqeD" + }, + "source": [ + "[![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/MemoryPal_Search_Agent.ipynb)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Ls8fyQsTnXqR" + }, + "source": [ + "# Install Dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "HihjK38YncNS" + }, + "outputs": [], + "source": [ + "!pip install praisonaiagents duckduckgo-search" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "drGND5XAnpzd" + }, + "source": [ + "# Set API Key" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "nkpbgwJwnrn_" + }, + "outputs": [], + "source": [ + "import os\n", + "\n", + "# Enter your OpenAI API key here\n", + "os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your OpenAI API key" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "19dqWac7nzZf" + }, + "source": [ + "# Tool Definition" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "id": "_M7EI96dn0qi" + }, + "outputs": [], + "source": [ + "from duckduckgo_search import DDGS\n", + "\n", + "def internet_search_tool(query: str):\n", + " results = []\n", + " ddgs = DDGS()\n", + " for result in ddgs.text(keywords=query, max_results=5):\n", + " results.append({\n", + " 'title': result.get('title', ''),\n", + " 'url': result.get('href', ''),\n", + " 'snippet': result.get('body', '')\n", + " })\n", + " return results" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "SYPI8zhen4nd" + }, + "source": [ + "# YAML Agent Config" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Yag6EqYOn5h-", + "outputId": "03f37769-3f05-479d-8d5a-a201bf403c73" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'framework': 'praisonai', 'topic': 'internet search demo', 'roles': {'searcher': {'backstory': 'Expert in internet search.', 'goal': 'Find information online.', 'role': 'Searcher', 'tools': ['internet_search_tool'], 'tasks': {'search_task': {'description': \"Search for 'AI job trends in 2025'.\", 'expected_output': 'List of search results.'}}}}}\n" + ] + } + ], + "source": [ + "import yaml\n", + "\n", + "yaml_config = \"\"\"\n", + "framework: praisonai\n", + "topic: internet search demo\n", + "roles:\n", + " searcher:\n", + " backstory: Expert in internet search.\n", + " goal: Find information online.\n", + " role: Searcher\n", + " tools:\n", + " - internet_search_tool\n", + " tasks:\n", + " search_task:\n", + " description: Search for 'AI job trends in 2025'.\n", + " expected_output: List of search results.\n", + "\"\"\"\n", + "\n", + "config = yaml.safe_load(yaml_config)\n", + "print(config)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "KbYjwEkvoUqV" + }, + "source": [ + "# Prompt Example" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "7hslONZgoXph" + }, + "source": [ + "Example prompt to use with the agent: \n", + "`Search about AI job trends in 2025`" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "KvzzBm-7oZ9c" + }, + "source": [ + "# Main: Run the Agent" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000, + "referenced_widgets": [ + "4a9625800fe94aabb88e2ff78bce5a1d", + "930e61499fac44f183c51ca93e3aad88", + "bfb62f3af49c40f7934a7f245cd57d6d", + "50486df133bf4e1582880c2cd6f2ca54" + ] + }, + "id": "TxyynCXCobA0", + "outputId": "148a9670-ebd7-4d23-e248-1e5cf13aeb8e" + }, + "outputs": [ + { + "data": { + "text/html": [ + "
╭─ Agent Info ────────────────────────────────────────────────────────────────────────────────────────────────────╮\n",
+       "                                                                                                                 \n",
+       "  👤 Agent: Agent                                                                                                \n",
+       "  Role: Assistant                                                                                                \n",
+       "  Tools: internet_search_tool                                                                                    \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[1;38;2;134;167;137mTools:\u001b[0m \u001b[3;38;2;180;212;255minternet_search_tool\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": "4a9625800fe94aabb88e2ff78bce5a1d", + "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": [ + "
╭──────────────────────────────────────────────── Tool Call ────────────────────────────────────────────────╮\n",
+       " Agent Agent is calling function 'internet_search_tool' with arguments: {'query': 'AI job trends in 2025'} \n",
+       "╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[32m╭─\u001b[0m\u001b[32m───────────────────────────────────────────────\u001b[0m\u001b[32m Tool Call \u001b[0m\u001b[32m───────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mAgent Agent is calling function 'internet_search_tool' with arguments: {'query': 'AI job trends in 2025'}\u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
╭─────────────────────────────────────────────────── Tool Call ───────────────────────────────────────────────────╮\n",
+       " Function 'internet_search_tool' returned: [{\"title\": \"AI Job Trends 2025: Top AI Jobs, Roles, and Hiring Data   \n",
+       " Insights\", \"url\": \"https://blog.getaura.ai/ai-job-trends-2025\", \"snippet\": \"Explore the latest AI job trends    \n",
+       " for 2025. Learn about top industries hiring, in-demand skills, and emerging roles shaping the future of AI      \n",
+       " hiring.\"}, {\"title\": \" The Fearless Future: 2025 Global AI Jobs Barometer - PwC\", \"url\":                        \n",
+       " \"https://www.pwc.com/gx/en/issues/artificial-intelligence/job-barometer/aijb-2025-united-states-analysis.pdf\",  \n",
+       " \"snippet\": \"Global Insights The AI Jobs Barometer reveals AI's global impact on jobs, wages, skills, and        \n",
+       " productivity by examining close to a billion job ads from six continents.\"}, {\"title\": \"10 Hottest AI Jobs Of   \n",
+       " 2025 With Six-Figure Salaries - Forbes\", \"url\":                                                                 \n",
+       " \"https://www.forbes.com/sites/bryanrobinson/2025/01/17/10-hottest-ai-jobs-of-2025-paying-six-figure-salaries/\", \n",
+       " \"snippet\": \"Explore the top AI roles of 2025, from Machine Learning Engineers to NLP Specialists, offering      \n",
+       " six-figure salaries and high demand in the evolving tech landscape.\"}, {\"title\": \"AI Job Market 2025: Impact on \n",
+       " Employment & Future Workforce Trends\", \"url\":                                                                   \n",
+       " \"https://www.cognitivetoday.com/2025/03/ai-job-market-impact-on-employment-future-workforce-trends/\",           \n",
+       " \"snippet\": \"Discover how AI will reshape jobs in 2025. Learn about AI-driven displacement, new roles, and       \n",
+       " must-have skills to thrive in the evolving workforce. AI Job Market 2025.\"}, {\"title\": \"AI Job Market: Trends,  \n",
+       " Opportunities, and Key Skills for 2025\", \"url\":                                                                 \n",
+       " \"https://www.analyticsinsight.net/artificial-intelligence/ai-job-market-trends-opportunities-and-key-skills-for \n",
+       " -2025\", \"snippet\": \"As artificial intelligence (AI) continues to reshape industries, the job market will see a  \n",
+       " significant transformation in 2025. With new opportunities emerging and certain skills becoming essential, AI   \n",
+       " adoption will also rise. From automation and machine learning to AI-driven healthcare and edge computing,       \n",
+       " understanding the evolving trends and required skill sets will be crucial for anyone ...\"}]                     \n",
+       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[32m╭─\u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m Tool Call \u001b[0m\u001b[32m──────────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mFunction 'internet_search_tool' returned: [{\"title\": \"AI Job Trends 2025: Top AI Jobs, Roles, and Hiring Data \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mInsights\", \"url\": \"https://blog.getaura.ai/ai-job-trends-2025\", \"snippet\": \"Explore the latest AI job trends \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mfor 2025. Learn about top industries hiring, in-demand skills, and emerging roles shaping the future of AI \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mhiring.\"}, {\"title\": \" The Fearless Future: 2025 Global AI Jobs Barometer - PwC\", \"url\": \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m\"https://www.pwc.com/gx/en/issues/artificial-intelligence/job-barometer/aijb-2025-united-states-analysis.pdf\", \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m\"snippet\": \"Global Insights The AI Jobs Barometer reveals AI's global impact on jobs, wages, skills, and \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mproductivity by examining close to a billion job ads from six continents.\"}, {\"title\": \"10 Hottest AI Jobs Of \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m2025 With Six-Figure Salaries - Forbes\", \"url\": \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m\"https://www.forbes.com/sites/bryanrobinson/2025/01/17/10-hottest-ai-jobs-of-2025-paying-six-figure-salaries/\",\u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m\"snippet\": \"Explore the top AI roles of 2025, from Machine Learning Engineers to NLP Specialists, offering \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36msix-figure salaries and high demand in the evolving tech landscape.\"}, {\"title\": \"AI Job Market 2025: Impact on\u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mEmployment & Future Workforce Trends\", \"url\": \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m\"https://www.cognitivetoday.com/2025/03/ai-job-market-impact-on-employment-future-workforce-trends/\", \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m\"snippet\": \"Discover how AI will reshape jobs in 2025. Learn about AI-driven displacement, new roles, and \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mmust-have skills to thrive in the evolving workforce. AI Job Market 2025.\"}, {\"title\": \"AI Job Market: Trends, \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36mOpportunities, and Key Skills for 2025\", \"url\": \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m\"https://www.analyticsinsight.net/artificial-intelligence/ai-job-market-trends-opportunities-and-key-skills-for\u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36m-2025\", \"snippet\": \"As artificial intelligence (AI) continues to reshape industries, the job market will see a \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36msignificant transformation in 2025. With new opportunities emerging and certain skills becoming essential, AI \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36madoption will also rise. From automation and machine learning to AI-driven healthcare and edge computing, \u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m│\u001b[0m \u001b[1;36munderstanding the evolving trends and required skill sets will be crucial for anyone ...\"}]\u001b[0m \u001b[32m│\u001b[0m\n", + "\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "bfb62f3af49c40f7934a7f245cd57d6d", + "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 14.7s\n",
+       "
\n" + ], + "text/plain": [ + "\u001b[2mResponse generated in 14.7s\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
╭───────────────────────────────────────────────────── Task ──────────────────────────────────────────────────────╮\n",
+       " AI job trends in 2025                                                                                           \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 AI job trends in 2025 \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
╭─────────────────────────────────────────────────── Response ────────────────────────────────────────────────────╮\n",
+       " Here are some insights into AI job trends for 2025:                                                             \n",
+       "                                                                                                                 \n",
+       "  1 Top AI Jobs and Roles: The AI job market in 2025 is expected to feature roles such as Machine Learning       \n",
+       "    Engineers, NLP Specialists, and other positions offering six-figure salaries. These roles are in high demand \n",
+       "    as the tech landscape evolves. Read more on Forbes.                                                          \n",
+       "  2 Industries and Skills: AI is reshaping industries, with new opportunities emerging and certain skills        \n",
+       "    becoming essential. Key areas include automation, machine learning, AI-driven healthcare, and edge           \n",
+       "    computing. Explore more on Analytics Insight.                                                                \n",
+       "  3 Global Impact: The AI Jobs Barometer by PwC examines AI's global impact on jobs, wages, skills, and          \n",
+       "    productivity, analyzing job ads from six continents. Check the PwC report.                                   \n",
+       "  4 Future Workforce Trends: AI will reshape jobs, leading to AI-driven displacement and the creation of new     \n",
+       "    roles. Understanding these trends and acquiring must-have skills will be crucial for thriving in the         \n",
+       "    evolving workforce. Learn more on Cognitive Today.                                                           \n",
+       "  5 Hiring Data Insights: Insights into the latest AI job trends, including top industries hiring and emerging   \n",
+       "    roles, can be found in various reports and analyses. Read more on GetAura.                                   \n",
+       "                                                                                                                 \n",
+       " These resources provide a comprehensive overview of the anticipated changes and opportunities in the AI job     \n",
+       " market by 2025.                                                                                                 \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 Here are some insights into AI job trends for 2025: \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[1mTop AI Jobs and Roles\u001b[0m: The AI job market in 2025 is expected to feature roles such as Machine Learning \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mEngineers, NLP Specialists, and other positions offering six-figure salaries. These roles are in high demand \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mas the tech landscape evolves. \u001b]8;id=1080;https://www.forbes.com/sites/bryanrobinson/2025/01/17/10-hottest-ai-jobs-of-2025-paying-six-figure-salaries/\u001b\\\u001b[4;34mRead more on Forbes\u001b[0m\u001b]8;;\u001b\\. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 2 \u001b[0m\u001b[1mIndustries and Skills\u001b[0m: AI is reshaping industries, with new opportunities emerging and certain skills \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mbecoming essential. Key areas include automation, machine learning, AI-driven healthcare, and edge \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mcomputing. \u001b]8;id=337875;https://www.analyticsinsight.net/artificial-intelligence/ai-job-market-trends-opportunities-and-key-skills-for-2025\u001b\\\u001b[4;34mExplore more on Analytics Insight\u001b[0m\u001b]8;;\u001b\\. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 3 \u001b[0m\u001b[1mGlobal Impact\u001b[0m: The AI Jobs Barometer by PwC examines AI's global impact on jobs, wages, skills, and \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mproductivity, analyzing job ads from six continents. \u001b]8;id=455296;https://www.pwc.com/gx/en/issues/artificial-intelligence/job-barometer/aijb-2025-united-states-analysis.pdf\u001b\\\u001b[4;34mCheck the PwC report\u001b[0m\u001b]8;;\u001b\\. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 4 \u001b[0m\u001b[1mFuture Workforce Trends\u001b[0m: AI will reshape jobs, leading to AI-driven displacement and the creation of new \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mroles. Understanding these trends and acquiring must-have skills will be crucial for thriving in the \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mevolving workforce. \u001b]8;id=772466;https://www.cognitivetoday.com/2025/03/ai-job-market-impact-on-employment-future-workforce-trends/\u001b\\\u001b[4;34mLearn more on Cognitive Today\u001b[0m\u001b]8;;\u001b\\. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m 5 \u001b[0m\u001b[1mHiring Data Insights\u001b[0m: Insights into the latest AI job trends, including top industries hiring and emerging \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[1;33m \u001b[0mroles, can be found in various reports and analyses. \u001b]8;id=262366;https://blog.getaura.ai/ai-job-trends-2025\u001b\\\u001b[4;34mRead more on GetAura\u001b[0m\u001b]8;;\u001b\\. \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m These resources provide a comprehensive overview of the anticipated changes and opportunities in the AI job \u001b[36m│\u001b[0m\n", + "\u001b[36m│\u001b[0m market by 2025. \u001b[36m│\u001b[0m\n", + "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Response:\n", + "Here are some insights into AI job trends for 2025:\n", + "\n", + "1. **Top AI Jobs and Roles**: The AI job market in 2025 is expected to feature roles such as Machine Learning Engineers, NLP Specialists, and other positions offering six-figure salaries. These roles are in high demand as the tech landscape evolves. [Read more on Forbes](https://www.forbes.com/sites/bryanrobinson/2025/01/17/10-hottest-ai-jobs-of-2025-paying-six-figure-salaries/).\n", + "\n", + "2. **Industries and Skills**: AI is reshaping industries, with new opportunities emerging and certain skills becoming essential. Key areas include automation, machine learning, AI-driven healthcare, and edge computing. [Explore more on Analytics Insight](https://www.analyticsinsight.net/artificial-intelligence/ai-job-market-trends-opportunities-and-key-skills-for-2025).\n", + "\n", + "3. **Global Impact**: The AI Jobs Barometer by PwC examines AI's global impact on jobs, wages, skills, and productivity, analyzing job ads from six continents. [Check the PwC report](https://www.pwc.com/gx/en/issues/artificial-intelligence/job-barometer/aijb-2025-united-states-analysis.pdf).\n", + "\n", + "4. **Future Workforce Trends**: AI will reshape jobs, leading to AI-driven displacement and the creation of new roles. Understanding these trends and acquiring must-have skills will be crucial for thriving in the evolving workforce. [Learn more on Cognitive Today](https://www.cognitivetoday.com/2025/03/ai-job-market-impact-on-employment-future-workforce-trends/).\n", + "\n", + "5. **Hiring Data Insights**: Insights into the latest AI job trends, including top industries hiring and emerging roles, can be found in various reports and analyses. [Read more on GetAura](https://blog.getaura.ai/ai-job-trends-2025).\n", + "\n", + "These resources provide a comprehensive overview of the anticipated changes and opportunities in the AI job market by 2025.\n" + ] + } + ], + "source": [ + "from praisonaiagents import Agent\n", + "\n", + "agent = Agent(\n", + " instructions=\"You are an AI assistant with internet search capabilities.\",\n", + " tools=[internet_search_tool]\n", + ")\n", + "\n", + "# Main: Ask a question\n", + "query = 'AI job trends in 2025' # You can change this prompt\n", + "response = agent.start(query)\n", + "print('Response:')\n", + "print(response)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} From 3e3b4351d8e4a969a4a5006384b3b15a7479741d Mon Sep 17 00:00:00 2001 From: DhivyaBharathy <157012713+Dhivya-Bharathy@users.noreply.github.com> Date: Mon, 30 Jun 2025 17:42:26 +0530 Subject: [PATCH 5/7] Update and rename Chile_Government_Services_Assistant.ipynb to Government-Services-Assistant.ipynb --- ..._Assistant.ipynb => Government-Services-Assistant.ipynb} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename examples/cookbooks/{Chile_Government_Services_Assistant.ipynb => Government-Services-Assistant.ipynb} (97%) diff --git a/examples/cookbooks/Chile_Government_Services_Assistant.ipynb b/examples/cookbooks/Government-Services-Assistant.ipynb similarity index 97% rename from examples/cookbooks/Chile_Government_Services_Assistant.ipynb rename to examples/cookbooks/Government-Services-Assistant.ipynb index 774394e6..b410962c 100644 --- a/examples/cookbooks/Chile_Government_Services_Assistant.ipynb +++ b/examples/cookbooks/Government-Services-Assistant.ipynb @@ -6,7 +6,7 @@ "id": "ZH_nR-SvvkDG" }, "source": [ - "# Chile Government Services Assistant - AI Chatbot" + "# Government Services Assistant - AI Chatbot" ] }, { @@ -15,7 +15,7 @@ "id": "w8B741JgvpFj" }, "source": [ - "This notebook demonstrates how to use an AI-powered assistant to answer questions about Chilean government services and procedures, using the Firecrawl API and a friendly, step-by-step conversational approach." + "This notebook demonstrates how to use an AI-powered assistant to answer questions about government services and procedures, using the Firecrawl API and a friendly, step-by-step conversational approach." ] }, { @@ -297,4 +297,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} From 64324dd53479b034914a5443e235e61bc223c30d Mon Sep 17 00:00:00 2001 From: DhivyaBharathy <157012713+Dhivya-Bharathy@users.noreply.github.com> Date: Mon, 30 Jun 2025 17:42:49 +0530 Subject: [PATCH 6/7] Update and rename MemoryPal_Search_Agent.ipynb to Search_Agent.ipynb --- .../{MemoryPal_Search_Agent.ipynb => Search_Agent.ipynb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/cookbooks/{MemoryPal_Search_Agent.ipynb => Search_Agent.ipynb} (99%) diff --git a/examples/cookbooks/MemoryPal_Search_Agent.ipynb b/examples/cookbooks/Search_Agent.ipynb similarity index 99% rename from examples/cookbooks/MemoryPal_Search_Agent.ipynb rename to examples/cookbooks/Search_Agent.ipynb index 2aa12abf..dc9d3acf 100644 --- a/examples/cookbooks/MemoryPal_Search_Agent.ipynb +++ b/examples/cookbooks/Search_Agent.ipynb @@ -6,7 +6,7 @@ "id": "-j-8RaEinSgs" }, "source": [ - "# 🧠 MemoryPal (PraisonAI Edition)\n", + "# 🧠 Search_Agent (PraisonAI Edition)\n", "\n", "A minimal example of using PraisonAI's Agent with a custom internet search tool in Python, ready for Google Colab." ] From 755af1c80606e9a1f19fd5e857a1ec4f1fb827a1 Mon Sep 17 00:00:00 2001 From: DhivyaBharathy <157012713+Dhivya-Bharathy@users.noreply.github.com> Date: Mon, 30 Jun 2025 17:43:14 +0530 Subject: [PATCH 7/7] Rename Pocky_Cybersecurity_PoC_Agent.ipynb to Cybersecurity-PoC Agent.ipynb --- ...ersecurity_PoC_Agent.ipynb => Cybersecurity-PoC Agent.ipynb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/cookbooks/{Pocky_Cybersecurity_PoC_Agent.ipynb => Cybersecurity-PoC Agent.ipynb} (99%) diff --git a/examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb b/examples/cookbooks/Cybersecurity-PoC Agent.ipynb similarity index 99% rename from examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb rename to examples/cookbooks/Cybersecurity-PoC Agent.ipynb index 35b9642a..81f4e375 100644 --- a/examples/cookbooks/Pocky_Cybersecurity_PoC_Agent.ipynb +++ b/examples/cookbooks/Cybersecurity-PoC Agent.ipynb @@ -230,4 +230,4 @@ ] } ] -} \ No newline at end of file +}