From 0f2dc2b564d858ce173455cdb2da58bd8fc7c3c1 Mon Sep 17 00:00:00 2001 From: devops-vestradata Date: Wed, 25 Jun 2025 13:54:43 +0530 Subject: [PATCH 1/6] Add Chile Government Services Assistant Python script --- .../chile_government_services_assistant_.py | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 examples/python/tools/exa-tool/chile_government_services_assistant_.py diff --git a/examples/python/tools/exa-tool/chile_government_services_assistant_.py b/examples/python/tools/exa-tool/chile_government_services_assistant_.py new file mode 100644 index 00000000..d16449e1 --- /dev/null +++ b/examples/python/tools/exa-tool/chile_government_services_assistant_.py @@ -0,0 +1,141 @@ +# # -*- coding: utf-8 -*- +# """Chile_Government_Services_Assistant .ipynb + +# Automatically generated by Colab. + +# Original file is located at +# https://colab.research.google.com/drive/13IOn2Vhg0EUwuIGpVilImW0rEpYYMoFQ + +# # Chile Government Services Assistant - AI Chatbot + +# 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. + +# [![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) + +# # Install dependencies +# """ + +# !pip install flask firecrawl praisonaiagents google-genai python-dotenv deep-translator + +# """# Set API Keys""" + +import os + +os.environ['FIRECRAWL_API_KEY'] = "your api key here" +os.environ['OPENAI_API_KEY'] = "your api key here" + +# """# Import Libraries & Translator""" + +from firecrawl import FirecrawlApp, ScrapeOptions +from deep_translator import GoogleTranslator +import re + +def translate_to_spanish(text): + try: + return GoogleTranslator(source='auto', target='es').translate(text) + except Exception as e: + print("Translation to Spanish failed:", e) + return text + +def translate_to_english(text): + try: + # Remove Markdown images and None values before translation + text = str(text).replace("None", "") + text = re.sub(r'!\[.*?\]\(.*?\)', '', text) + return GoogleTranslator(source='auto', target='en').translate(text) + except Exception as e: + print("Translation to English failed:", e) + return text + +# """# Firecrawl Tool Class""" + +class FirecrawlTool: + def __init__(self, api_key, instruction: str, template: str): + if not api_key: + raise ValueError("Firecrawl API key not provided.") + self.app = FirecrawlApp(api_key=api_key) + self.instruction = instruction + self.template = template + + def search(self, search: str) -> str: + if not search or len(search) < 5: + return "Error: Please provide a valid search query (at least 5 characters)." + response_md = "" + try: + search_result = self.app.search( + query=self.instruction + search, + limit=2, + country="cl", + lang="es", # Always search in Spanish for best results + scrape_options=ScrapeOptions(formats=["markdown", "links"]) + ) + if search_result and hasattr(search_result, 'data') and search_result.data: + filtered_results = [ + result for result in search_result.data + if str(result.get("url", "")).startswith("https://www.chileatiende.gob.cl/fichas") and not str(result.get("url", "")).endswith("pdf") + ] + if filtered_results: + for num, result in enumerate(filtered_results, start=1): + response_md += self.template.format( + result_number=num, + page_title=str(result.get("title", "")), + page_url=str(result.get("url", "")), + page_content=str(result.get("markdown", "")) + ) + return response_md + else: + return None + else: + return None + except Exception as e: + return f"Error during search: {e}" + +# """# Firecrawl Prompt Template""" + +# FIRECRAWL_INSTRUCTION = "ChileAtiende: " +# FIRECRAWL_TEMPLATE = """ +# # Result {result_number} + +# ## Page Name: +# "{page_title}" + +# ## URL: +# {page_url} + +# ## Content: +# {page_content} + +# """ + +# """# Initialize Firecrawl Tool""" + +firecrawl_tool = FirecrawlTool( + api_key=os.environ['FIRECRAWL_API_KEY'], + instruction=FIRECRAWL_INSTRUCTION, + template=FIRECRAWL_TEMPLATE +) + +# """# Main Chat Loop""" + +print("Hello! I am your ChileAtiende assistant, Tomás. How can I help you today?") +print("You can ask me, for example: How to renew your ID card, How to apply for the Winter Bonus, etc.") + +while True: + user_input = input("\nYou: ") + if user_input.lower() in ["exit", "quit"]: + print("Tomás: It was a pleasure to help you. Goodbye!") + break + + # Translate English input to Spanish for Firecrawl + spanish_query = translate_to_spanish(user_input) + spanish_answer = firecrawl_tool.search(spanish_query) + + # Only translate if we got a real answer + if spanish_answer and isinstance(spanish_answer, str) and spanish_answer.strip() and "Error" not in spanish_answer: + try: + english_answer = translate_to_english(spanish_answer) + print("\nTomás (in English):\n", english_answer) + except Exception as e: + print(f"\nTomás: I found information, but couldn't translate it. Here it is in Spanish:\n{spanish_answer}\n(Translation error: {e})") + else: + print("\nTomás: Sorry, I couldn't find relevant information. Try rephrasing your question or ask about another service.") \ No newline at end of file From cf4229ab511dc4d2a3e47b1651fbf25def637f17 Mon Sep 17 00:00:00 2001 From: devops-vestradata Date: Wed, 25 Jun 2025 16:29:19 +0530 Subject: [PATCH 2/6] Add pocky_cybersecurity_poc_agent Python Script --- .../exa-tool/pocky_cybersecurity_poc_agent.py | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py diff --git a/examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py b/examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py new file mode 100644 index 00000000..351be4c7 --- /dev/null +++ b/examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +"""Pocky_Cybersecurity_PoC_Agent.ipynb + +Automatically generated by Colab. + +Original file is located at + https://colab.research.google.com/drive/1hnNLGS90GopXOhwHHIqxaGJERcajSMQJ + +# Pocky Query Tool: Automated CVE PoC Search & Validation + +A lightweight, web-scale agent that helps you find, filter, and fetch real-world PoC exploits — so you don't have to. + +**Features:** +- Automatically searches multiple security-related websites +- Intelligently analyzes and extracts PoC code +- Automatically selects the most reliable PoC samples +- Supports collection of PoCs from multiple sources + +[![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) + +# Install Dependencies +""" + +!pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4 + +"""# Set API Keys""" + +import os + +# Set your API keys here (replace with your actual keys) +os.environ["EXA_API_KEY"] = "your api key" +os.environ["OPENAI_API_KEY"] = "your api key" +os.environ["OPENAI_BASE_URL"] = "https://api.openai.com/v1" # Optional, for custom OpenAI endpoints + +"""# Tools (Core Functions)""" + +import json +from openai import OpenAI +from exa_py import Exa + +# Dummy/Minimal agent classes for notebook demo +class ValidationAgent: + def __init__(self, input_json): + self.input_json = input_json + def run(self): + # Dummy validation logic for notebook demo + data = json.loads(self.input_json) + return True if "attack_intent" in data and "poc_sample" in data else False + +class AttackIntentAgent: + def __init__(self, description): + self.description = description + def run(self): + # Dummy intent extraction for notebook demo + return f"Intent for: {self.description[:50]}..." + +"""## YAML Prompt (Validation Example) +This is the prompt used for PoC validation. +""" + +validation_prompt = """ +You are a highly skilled technical assistant with deep expertise in PoC sample validation. + +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. + +Specifically: +- Understand the CVE's attack intent, including the attack goal and the underlying exploitation mechanism. +- Analyze the PoC to determine whether it is designed to achieve this intent. +- Check whether the payloads, request structures, and overall logic of the PoC align with the described attack intent. +- You do not need to execute the PoC. Focus on static validation through reasoning and consistency. + +Your output must be a JSON object with two fields: +- "valid": a boolean indicating whether the PoC correctly reflects the attack intent. +- "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. +""" +print(validation_prompt) + +"""# Main (Query and Validate a CVE PoC)""" + +def run_pocky_for_cve(cve_id): + # Example: Simulate fetching a description and PoC (replace with real logic) + description = f"Description for {cve_id} (replace with real Exa/OpenAI search)" + poc_sample = f"PoC code for {cve_id} (replace with real PoC search)" + + # Stage 2: Attack Intent + intent = AttackIntentAgent(description).run() + print(f"Attack Intent: {intent}") + + # Stage 3: Validation + validation_input = json.dumps({"attack_intent": intent, "poc_sample": poc_sample}, indent=2) + valid = ValidationAgent(validation_input).run() + print(f"Validation Result: {valid}") + if valid: + print(f"PoC for {cve_id} is valid and ready to use.") + else: + print(f"PoC for {cve_id} failed validation.") + +"""# Example Usage""" + +run_pocky_for_cve("CVE-2023-4450") \ No newline at end of file From 5a57b4cfbe4320973ba7fb052fe6a63750a8ccf1 Mon Sep 17 00:00:00 2001 From: devops-vestradata Date: Wed, 25 Jun 2025 19:03:48 +0530 Subject: [PATCH 3/6] Add LegaliaAi Minicourt --- .../tools/exa-tool/legaliaai_minicourt.py | 208 ++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 examples/python/tools/exa-tool/legaliaai_minicourt.py diff --git a/examples/python/tools/exa-tool/legaliaai_minicourt.py b/examples/python/tools/exa-tool/legaliaai_minicourt.py new file mode 100644 index 00000000..4c39f83f --- /dev/null +++ b/examples/python/tools/exa-tool/legaliaai_minicourt.py @@ -0,0 +1,208 @@ +# # -*- coding: utf-8 -*- +# """LegaliaAI_MiniCourt.ipynb + +# Automatically generated by Colab. + +# Original file is located at +# https://colab.research.google.com/drive/1Pc6GCFJN9Fyq_oP4MCtPmeTSt_AZmRMT + +# # ⚖️ Legalia AI - Mini Court Simulation + +# A simplified court case simulation with essential AI agents. + +# [![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) + +# ## Install Dependencies +# """ + +# !pip install praisonaiagents openai python-dotenv + +# """## Import Libraries & Setup""" + +import os +from dotenv import load_dotenv +from IPython.display import display, HTML +import time + +load_dotenv() + +# Setup API key +api_key = os.getenv('OPENAI_API_KEY') +if not api_key: + print("🔑 Enter your OpenAI API key:") + api_key = input("API Key: ").strip() + os.environ['OPENAI_API_KEY'] = "Enter your api key" + +print("✅ Setup complete!") + +# """## Create Mini Agents""" + +from praisonaiagents import Agent + +# Judge Agent +judge = Agent( + name="Judge", + role="Preside over court proceedings", + llm="gpt-4o-mini", + instructions=[ + "You are an impartial judge", + "Make fair decisions based on evidence", + "Keep responses under 100 words" + ], + markdown=True +) + +# Prosecutor Agent +prosecutor = Agent( + name="Prosecutor", + role="Present case against defendant", + llm="gpt-4o-mini", + instructions=[ + "You are a prosecutor seeking conviction", + "Present evidence methodically", + "Keep responses under 80 words" + ], + markdown=True +) + +# Defense Agent +defense = Agent( + name="Defense", + role="Defend the accused", + llm="gpt-4o-mini", + instructions=[ + "You are a defense attorney", + "Create reasonable doubt", + "Keep responses under 80 words" + ], + markdown=True +) + +# Witness Agent +witness = Agent( + name="Witness", + role="Provide testimony", + llm="gpt-4o-mini", + instructions=[ + "You are a witness testifying", + "Provide factual testimony", + "Keep responses under 60 words" + ], + markdown=True +) + +print("✅ Mini agents created!") + +"""# Case Details Input""" + +# Simple case details +case_title = input("Case Title (e.g., 'State vs. Smith'): ") or "State vs. Smith" +case_description = input("Case Description: ") or "Theft case involving stolen laptop" +evidence = input("Key Evidence: ") or "Security camera footage and witness testimony" + +print(f"\n📋 Case: {case_title}") +print(f"📝 Description: {case_description}") +print(f"🔍 Evidence: {evidence}") + +"""# Helper Functions (Fixed with .start())## Cell 4: Case Details Input""" + +# Display function +def show_message(name, role, message, color="#4CAF50"): + html = f""" +
+ ⚖️ {name}{role}
+
{message}
+
+ """ + display(HTML(html)) + +# Run agent using .start() +def run_agent(agent, prompt, name, role, color="#4CAF50"): + try: + response = agent.start(prompt) + show_message(name, role, response, color) + return response + except Exception as e: + show_message("System", "Error", str(e), "#f44336") + return "" + +"""## Mini Court Simulation""" + +# Mini court simulation +print("🚀 Starting Mini Court Simulation...") + +# Day 1: Opening +display(HTML(f"

📅 Day 1: Opening Statements

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

📅 Day 2: Witness Testimony

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

📅 Day 3: Final Verdict

")) + +# Judge's verdict +verdict_prompt = f""" +You are Judge presiding over "{case_title}". +Deliver your final verdict. +Consider all evidence: {evidence} +Be fair and explain your reasoning. +""" +verdict_response = run_agent(judge, verdict_prompt, "Judge", "Final Verdict", "#8B4513") + +print("\n✅ Mini court simulation completed!") + +# """# Summary""" + +print("🎯 Mini Legalia AI Complete!") +print("\nThis simplified version demonstrates:") +print("- 4 Essential Agents: Judge, Prosecutor, Defense, Witness") +print("- 3-Day Trial: Opening, Testimony, Verdict") +print("- Real-time Interaction: Each agent responds based on case context") +print("- Easy Setup: Minimal dependencies and configuration") +print("\nPerfect for quick demonstrations and learning! ⚖️") From dea4a7f54d6728945ba511147eb614cc64ef44bf Mon Sep 17 00:00:00 2001 From: devops-vestradata Date: Thu, 26 Jun 2025 13:54:36 +0530 Subject: [PATCH 4/6] Add praison_ai_real_estate_chatbot --- .../praison_ai_real_estate_chatbot.py | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py diff --git a/examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py b/examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py new file mode 100644 index 00000000..e54dddd2 --- /dev/null +++ b/examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py @@ -0,0 +1,65 @@ +# # -*- coding: utf-8 -*- +# """Praison_AI_Real_Estate_Chatbot.ipynb + +# Automatically generated by Colab. + +# Original file is located at +# https://colab.research.google.com/drive/1E06aeVop9cUqumuqKmF_beCRl_yF90pP + +# # Praison AI Real Estate Chatbot + +# Interact with a real estate AI assistant powered by PraisonAI and OpenAI. + +# [![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/Praison_AI_Real_Estate_Chatbot.ipynb) + +# ## 1. Install Dependencies +# """ + +# !pip install praisonaiagents openai + +# """## 2. Set Your OpenAI API Key""" + +import os + +# Enter your OpenAI API key here +OPENAI_API_KEY = "Enter your api key here" # <-- Replace with your key +os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY + +# """## 3. Create the Praison AI Agent""" + +from praisonaiagents import Agent + +praison_agent = Agent( + name="Praison Real Estate Chatbot", + role="Answer real estate questions and provide helpful advice.", + instructions=[ + "You are a helpful real estate assistant.", + "Answer user questions about buying, selling, or renting property.", + "Provide clear, concise, and friendly advice." + ], + markdown=True +) + +# """## 4. Chat with the Agent""" + +import ipywidgets as widgets +from IPython.display import display, Markdown + +def ask_agent(question): + # Use the .chat() method for the public praisonaiagents package + response = praison_agent.chat(question) + display(Markdown(f"**Praison AI:** {response}")) + +question = widgets.Text( + value='', + placeholder='Type your real estate question here...', + description='You:', + disabled=False +) +button = widgets.Button(description="Ask Praison AI") + +def on_button_clicked(b): + ask_agent(question.value) + +button.on_click(on_button_clicked) +display(question, button) \ No newline at end of file From 76620770967e2a7d82ec6cea854d20322f1682ff Mon Sep 17 00:00:00 2001 From: devops-vestradata Date: Thu, 26 Jun 2025 15:30:06 +0530 Subject: [PATCH 5/6] Add MemoryPal Search Agent --- .../tools/exa-tool/memorypal_search_agent.py | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 examples/python/tools/exa-tool/memorypal_search_agent.py diff --git a/examples/python/tools/exa-tool/memorypal_search_agent.py b/examples/python/tools/exa-tool/memorypal_search_agent.py new file mode 100644 index 00000000..9797fbfe --- /dev/null +++ b/examples/python/tools/exa-tool/memorypal_search_agent.py @@ -0,0 +1,84 @@ +# # -*- coding: utf-8 -*- +# """MemoryPal_Search_Agent.ipynb + +# Automatically generated by Colab. + +# Original file is located at +# https://colab.research.google.com/drive/1WgSFiFu1dbUw93-Pwv3K_KP1AuBenZjC + +# # 🧠 MemoryPal (PraisonAI Edition) + +# A minimal example of using PraisonAI's Agent with a custom internet search tool in Python, ready for Google Colab. + +# [![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) + +# # Install Dependencies +# """ + +# !pip install praisonaiagents duckduckgo-search + +# """# Set API Key""" + +import os + +# Enter your OpenAI API key here +os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your OpenAI API key + +# """# Tool Definition""" + +from duckduckgo_search import DDGS + +def internet_search_tool(query: str): + results = [] + ddgs = DDGS() + for result in ddgs.text(keywords=query, max_results=5): + results.append({ + 'title': result.get('title', ''), + 'url': result.get('href', ''), + 'snippet': result.get('body', '') + }) + return results + +# """# YAML Agent Config""" + +import yaml + +yaml_config = """ +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. +""" + +config = yaml.safe_load(yaml_config) +print(config) + +# """# Prompt Example + +# Example prompt to use with the agent: +# `Search about AI job trends in 2025` + +# Main: Run the Agent +# """ + +from praisonaiagents import Agent + +agent = Agent( + instructions="You are an AI assistant with internet search capabilities.", + tools=[internet_search_tool] +) + +# Main: Ask a question +query = 'AI job trends in 2025' # You can change this prompt +response = agent.start(query) +print('Response:') +print(response) \ No newline at end of file From ad70771b3ed48af42aa52b5069d8bf3ae914d850 Mon Sep 17 00:00:00 2001 From: devops-vestradata Date: Thu, 26 Jun 2025 16:55:49 +0530 Subject: [PATCH 6/6] Add Intelligent_Cognitive_Agent --- .../exa-tool/intelligent_cognitive_agent.py | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 examples/python/tools/exa-tool/intelligent_cognitive_agent.py diff --git a/examples/python/tools/exa-tool/intelligent_cognitive_agent.py b/examples/python/tools/exa-tool/intelligent_cognitive_agent.py new file mode 100644 index 00000000..763c8b65 --- /dev/null +++ b/examples/python/tools/exa-tool/intelligent_cognitive_agent.py @@ -0,0 +1,81 @@ +# # -*- coding: utf-8 -*- +# """Intelligent_Cognitive_Agent.ipynb + +# Automatically generated by Colab. + +# Original file is located at +# https://colab.research.google.com/drive/1UssW8MZyZpMX6oVjhqn4O6euxLLIVgGM + +# # 🧠 Cognitive Assistant Agent Team (PraisonAI) + +# This notebook demonstrates a multi-specialist cognitive assistant using PraisonAI, with each specialist as a tool. + +# [![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/Intelligent_Cognitive_Agent.ipynb) + +# # Install Dependencies +# """ + +# !pip install praisonaiagents + +# """# Set API Key""" + +import os + +# Set your OpenAI or OpenRouter API key for PraisonAI +os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your actual OpenAI or OpenRouter API key + +"""# Imports and Specialist Agent Definitions""" + +import re +from praisonaiagents import Agent + +# Dummy specialist agent classes for demonstration. +# Replace these with your actual specialist agent logic if needed. +class SpecialistAgent: + def __init__(self, name): + self.name = name + def run(self, query): + return f"{self.name} specialist response to: {query}" + +# Instantiate all specialist agents (replace with your real classes if available) +specialists = [ + SpecialistAgent("decision_risk_agent"), + SpecialistAgent("problem_solving_innovation_agent"), + SpecialistAgent("Systems___Complexity_Agent"), + SpecialistAgent("bias_psychology_agent"), + SpecialistAgent("Strategy___Competition_Agent"), + SpecialistAgent("Learning___Communication_Agent"), + SpecialistAgent("Efficiency___Process_Agent"), + SpecialistAgent("motivation_human_factors_agent"), +] + +"""# Tool Wrapping and Agent Setup""" + +def make_tool(agent): + def tool(query: str): + return agent.run(query) + # Sanitize the tool name to match PraisonAI's requirements + safe_name = re.sub(r'[^a-zA-Z0-9_-]', '_', agent.name or "tool") + tool.__name__ = safe_name + return tool + +tools = [make_tool(agent) for agent in specialists] + +agent = Agent( + instructions=""" + You are a cognitive assistant with access to a set of specialist tools (decision making, problem solving, systems thinking, psychology, strategy, learning, efficiency, motivation). + Use the most relevant tool(s) to answer the user's query. + """, + tools=tools, +) + +# """# User Query and Agent Response""" + +user_query = input("Ask your question (or type 'quit' to exit): ") +while user_query.lower() != 'quit': + print("\n--- Thinking ---") + response = agent.start(user_query) + print(response) + print("\n---------------") + user_query = input("Ask your question (or type 'quit' to exit): ") +print("Cognitive Assistant Agent Team - Finished.") \ No newline at end of file