Skip to content

Add Intelligent Cognitive Agent Python Script #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Dhivya-Bharathy
Copy link
Contributor

@Dhivya-Bharathy Dhivya-Bharathy commented Jun 26, 2025

Implemented the Cognitive Assistant Agent Team using PraisonAI.
Specialist agents are integrated as tools within a single intelligent agent.
Enables interactive command-line Q&A with modular cognitive expertise.

Summary by CodeRabbit

  • New Features
    • Introduced an AI assistant for Chilean government services, supporting English and Spanish queries.
    • Added an intelligent cognitive agent with multiple specialist domains for enhanced query handling.
    • Implemented a mini court simulation with interactive AI agents representing Judge, Prosecutor, Defense, and Witness roles.
    • Provided an agent-powered internet search tool for quick information retrieval using DuckDuckGo.
    • Launched a cybersecurity agent to automate validation of proof-of-concept exploits for CVE vulnerabilities.
    • Released a real estate chatbot for interactive property-related advice and information.

Copy link
Contributor

coderabbitai bot commented Jun 26, 2025

Walkthrough

Several new Python scripts were added, each implementing a distinct AI-powered assistant or agent for specialized tasks: a Chilean government services chatbot, an intelligent cognitive agent using PraisonAI, a mini court simulation with multiple AI roles, a search agent leveraging DuckDuckGo, a cybersecurity PoC validation agent, and a real estate chatbot with an interactive UI.

Changes

File(s) Change Summary
.../chile_government_services_assistant_.py Added AI chatbot for Chilean government services using Firecrawl API and translation helpers.
.../intelligent_cognitive_agent.py Introduced cognitive assistant with multiple specialist agents using PraisonAI framework.
.../legaliaai_minicourt.py Implemented mini court simulation with AI agents for Judge, Prosecutor, Defense, and Witness roles.
.../memorypal_search_agent.py Added search agent example integrating PraisonAI and DuckDuckGo for internet search tasks.
.../pocky_cybersecurity_poc_agent.py Introduced cybersecurity PoC validation agent for CVE vulnerabilities with attack intent extraction.
.../praison_ai_real_estate_chatbot.py Created interactive real estate chatbot using PraisonAI and OpenAI, with IPython widget-based chat interface.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Agent
    participant Tool/API

    User->>Agent: Submit query
    Agent->>Tool/API: Process query (search, validate, etc.)
    Tool/API-->>Agent: Return results/response
    Agent-->>User: Deliver formatted response
Loading

Suggested labels

Review effort 2/5

Poem

In the warren of code, new helpers appear,
Agents for courtrooms, for homes far and near.
They search and they chat, translate with flair,
Solve puzzles, find trends, and validate with care.
🐇 With each clever script, our toolkit grows bright—
AI bunnies at work, hopping into the light!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @Dhivya-Bharathy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the examples directory by adding a suite of new Python scripts. These scripts illustrate diverse use cases for AI agents powered by the PraisonAI framework, ranging from interactive chatbots for specific domains like government services and real estate, to complex simulations like a mini court, and practical applications such as internet search and cybersecurity proof-of-concept validation. The additions aim to showcase the modularity and extensibility of PraisonAI by integrating various specialist agents and external tools.

Highlights

  • New Examples for PraisonAI Agents: Introduced six new Python scripts demonstrating various applications of AI agents built with the PraisonAI framework, showcasing its versatility.
  • Cognitive Assistant Team: Added intelligent_cognitive_agent.py, which implements a multi-specialist cognitive assistant where each specialist acts as a tool for a central PraisonAI agent, enabling interactive command-line Q&A.
  • Domain-Specific AI Assistants: Included specialized agents such as a 'Chile Government Services Assistant' (chile_government_services_assistant_.py) using Firecrawl and translation, a 'Legalia AI Mini Court Simulation' (legaliaai_minicourt.py) with distinct judge, prosecutor, defense, and witness agents, and a 'Real Estate Chatbot' (praison_ai_real_estate_chatbot.py).
  • Tool Integration Demonstrations: Provided examples of integrating external tools: memorypal_search_agent.py demonstrates internet search using DuckDuckGo, and pocky_cybersecurity_poc_agent.py outlines a framework for CVE PoC search and validation, simulating external API calls.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

codecov bot commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 14.50%. Comparing base (e9f23e1) to head (ad70771).
Report is 170 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #698   +/-   ##
=======================================
  Coverage   14.50%   14.50%           
=======================================
  Files          25       25           
  Lines        2517     2517           
  Branches      357      357           
=======================================
  Hits          365      365           
  Misses       2136     2136           
  Partials       16       16           
Flag Coverage Δ
quick-validation 0.00% <ø> (ø)
unit-tests 14.50% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The code changes introduce several new Python scripts that implement intelligent cognitive agents using the PraisonAI framework. The scripts cover various use cases, including a Chile government services assistant, a mini court simulation, a cybersecurity PoC agent, and a real estate chatbot. The most significant issue across all scripts is the hardcoding of API keys, which poses a significant security risk.


import os

os.environ['FIRECRAWL_API_KEY'] = "your api key here"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

Suggested change
os.environ['FIRECRAWL_API_KEY'] = "your api key here"
# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# os.environ['FIRECRAWL_API_KEY'] = os.getenv('FIRECRAWL_API_KEY')
os.environ['FIRECRAWL_API_KEY'] = "your api key here"

import os

os.environ['FIRECRAWL_API_KEY'] = "your api key here"
os.environ['OPENAI_API_KEY'] = "your api key here"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

Suggested change
os.environ['OPENAI_API_KEY'] = "your api key here"
# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY')
os.environ['OPENAI_API_KEY'] = "your api key here"

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

Suggested change
os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your actual OpenAI or OpenRouter API key
# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY')
os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your actual OpenAI or OpenRouter 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

Suggested change
os.environ['OPENAI_API_KEY'] = "Enter your api key"
# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY')
os.environ['OPENAI_API_KEY'] = "Enter your 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

Suggested change
os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your OpenAI API key
# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY')
os.environ['OPENAI_API_KEY'] = 'Enter your api key' # <-- Replace with your OpenAI API key

import os

# Set your API keys here (replace with your actual keys)
os.environ["EXA_API_KEY"] = "your api key"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# os.environ["EXA_API_KEY"] = os.getenv("EXA_API_KEY")
os.environ["EXA_API_KEY"] = "your api key"


# 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
os.environ["OPENAI_API_KEY"] = "your api key"

import os

# Enter your OpenAI API key here
OPENAI_API_KEY = "Enter your api key here" # <-- Replace with your key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Consider using a more secure method for handling API keys, such as storing them in a dedicated secrets management system or using environment variables with restricted access. Hardcoding API keys directly in the script poses a security risk if the code is exposed. This is a critical issue.

Suggested change
OPENAI_API_KEY = "Enter your api key here" # <-- Replace with your key
# Use a more secure method to load API keys
# For example, using python-dotenv and loading from a .env file
# from dotenv import load_dotenv
# load_dotenv()
# OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
OPENAI_API_KEY = "Enter your api key here" # <-- Replace with your key

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 16

🧹 Nitpick comments (6)
examples/python/tools/exa-tool/legaliaai_minicourt.py (2)

40-93: Consider following PraisonAI Agent best practices.

Based on the retrieved learnings, Agent definitions should include more comprehensive parameters for better functionality.

Consider enhancing the agent definitions with additional parameters:

 judge = Agent(
     name="Judge",
     role="Preside over court proceedings",
+    goal="Ensure fair and impartial court proceedings",
+    backstory="Experienced judge with years of legal expertise",
     llm="gpt-4o-mini",
     instructions=[
         "You are an impartial judge",
         "Make fair decisions based on evidence",
         "Keep responses under 100 words"
     ],
     markdown=True
 )

141-141: Remove unnecessary f-string prefixes.

The f-strings don't contain any placeholders, making the f prefix redundant.

-display(HTML(f"<h2>📅 Day 1: Opening Statements</h2>"))
+display(HTML("<h2>📅 Day 1: Opening Statements</h2>"))

-display(HTML(f"<h2>📅 Day 2: Witness Testimony</h2>"))
+display(HTML("<h2>📅 Day 2: Witness Testimony</h2>"))

-display(HTML(f"<h2>📅 Day 3: Final Verdict</h2>"))
+display(HTML("<h2>📅 Day 3: Final Verdict</h2>"))

Also applies to: 173-173, 187-187

examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py (1)

32-41: Consider enhancing the Agent configuration.

Following PraisonAI best practices, consider adding more comprehensive parameters for better functionality.

 praison_agent = Agent(
     name="Praison Real Estate Chatbot",
     role="Answer real estate questions and provide helpful advice.",
+    goal="Provide accurate and helpful real estate guidance to users",
+    backstory="Expert real estate advisor with comprehensive market knowledge",
     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
 )
examples/python/tools/exa-tool/memorypal_search_agent.py (1)

46-63: The YAML configuration is defined but not utilized.

The YAML config is parsed and printed but not actually used by the agent, which may confuse users about its purpose.

Either remove the unused YAML configuration or integrate it into the agent setup:

-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)
+# Configuration could be integrated into agent setup if needed

Or integrate it properly:

+# Use config to set up agent
+searcher_config = config['roles']['searcher']
 agent = Agent(
-    instructions="You are an AI assistant with internet search capabilities.",
+    instructions=f"You are an AI assistant with internet search capabilities. {searcher_config['backstory']}",
+    role=searcher_config['role'],
+    goal=searcher_config['goal'],
     tools=[internet_search_tool]
 )
examples/python/tools/exa-tool/chile_government_services_assistant_.py (2)

77-87: Simplify the conditional logic.

The unnecessary else after return can be removed for cleaner code.

                 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
+                return None

52-91: Consider enhancing the FirecrawlTool class.

The class could benefit from additional methods and better error handling to make it more reusable.

Consider adding methods for different types of searches and better validation:

 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 validate_query(self, query: str) -> bool:
+        """Validate search query before processing."""
+        return query and len(query.strip()) >= 5
+    
+    def filter_results(self, results) -> list:
+        """Filter results to only include valid ChileAtiende pages."""
+        return [
+            result for result in results
+            if (str(result.get("url", "")).startswith("https://www.chileatiende.gob.cl/fichas") 
+                and not str(result.get("url", "")).endswith("pdf"))
+        ]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f3ce5c and ad70771.

📒 Files selected for processing (6)
  • examples/python/tools/exa-tool/chile_government_services_assistant_.py (1 hunks)
  • examples/python/tools/exa-tool/intelligent_cognitive_agent.py (1 hunks)
  • examples/python/tools/exa-tool/legaliaai_minicourt.py (1 hunks)
  • examples/python/tools/exa-tool/memorypal_search_agent.py (1 hunks)
  • examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py (1 hunks)
  • examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.cursorrules:0-0
Timestamp: 2025-06-24T05:57:49.377Z
Learning: The PraisonAIAgents class (in src/agents/agents.ts) is responsible for managing multiple agents, tasks, memory, process type, and acts as the orchestrator for agent interactions. It should accept configuration options for verbosity, completion checking, retries, process type, memory, and embedding.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: All major components (agents, workflows, tasks) in the PraisonAI Agents framework support asynchronous execution using Python's async/await syntax.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: Multi-agent workflows in praisonaiagents/agents/ (Python) should use PraisonAIAgents to orchestrate agents and tasks, supporting sequential, hierarchical, and parallel processes, with optional manager agents for hierarchical flows.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: When defining an Agent in praisonaiagents/agent/ (Python), always provide parameters for name, role, goal, backstory, LLM selection, self-reflection (with min/max iterations), optional tools, and guardrail logic (function or string) with a retry limit.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.windsurfrules:0-0
Timestamp: 2025-06-24T05:58:21.674Z
Learning: In the TypeScript/Node.js version of PraisonAI Agents, all references to LLM or litellm should be replaced with aisdk usage for large language model calls. The LLM class in src/llm/llm.ts should wrap aisdk.generateText and provide a response method for agent and task usage.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.cursorrules:0-0
Timestamp: 2025-06-24T05:57:49.377Z
Learning: In the TypeScript/Node.js version of PraisonAI Agents, all references to LLM or litellm should be replaced with aisdk usage for large language model calls. The LLM class in src/llm/llm.ts should wrap aisdk.generateText and provide a response method that returns a Promise<string>.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: Task objects in praisonaiagents/task/ (Python) should include a name, description, expected output, agent assignment, context for dependencies, optional structured output (Pydantic), and conditional execution logic.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.windsurfrules:0-0
Timestamp: 2025-06-24T05:58:21.674Z
Learning: The PraisonAIAgents class should manage multiple agents, tasks, memory, process type, and other configurations, acting as the orchestrator for agent and task interactions. It should support process types such as sequential, workflow, and hierarchical.
examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py (4)
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: When defining an Agent in praisonaiagents/agent/ (Python), always provide parameters for name, role, goal, backstory, LLM selection, self-reflection (with min/max iterations), optional tools, and guardrail logic (function or string) with a retry limit.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.windsurfrules:0-0
Timestamp: 2025-06-24T05:58:21.674Z
Learning: In the TypeScript/Node.js version of PraisonAI Agents, all references to LLM or litellm should be replaced with aisdk usage for large language model calls. The LLM class in src/llm/llm.ts should wrap aisdk.generateText and provide a response method for agent and task usage.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: All major components (agents, workflows, tasks) in the PraisonAI Agents framework support asynchronous execution using Python's async/await syntax.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.cursorrules:0-0
Timestamp: 2025-06-24T05:57:49.377Z
Learning: In the TypeScript/Node.js version of PraisonAI Agents, all references to LLM or litellm should be replaced with aisdk usage for large language model calls. The LLM class in src/llm/llm.ts should wrap aisdk.generateText and provide a response method that returns a Promise<string>.
examples/python/tools/exa-tool/legaliaai_minicourt.py (1)
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: When defining an Agent in praisonaiagents/agent/ (Python), always provide parameters for name, role, goal, backstory, LLM selection, self-reflection (with min/max iterations), optional tools, and guardrail logic (function or string) with a retry limit.
examples/python/tools/exa-tool/memorypal_search_agent.py (4)
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: When defining an Agent in praisonaiagents/agent/ (Python), always provide parameters for name, role, goal, backstory, LLM selection, self-reflection (with min/max iterations), optional tools, and guardrail logic (function or string) with a retry limit.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: When implementing tools in praisonaiagents/tools/ (Python), use either the @tool decorator for simple function-based tools or subclass BaseTool for more complex tools.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.cursorrules:0-0
Timestamp: 2025-06-24T05:57:49.377Z
Learning: The PraisonAIAgents class (in src/agents/agents.ts) is responsible for managing multiple agents, tasks, memory, process type, and acts as the orchestrator for agent interactions. It should accept configuration options for verbosity, completion checking, retries, process type, memory, and embedding.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: All major components (agents, workflows, tasks) in the PraisonAI Agents framework support asynchronous execution using Python's async/await syntax.
examples/python/tools/exa-tool/intelligent_cognitive_agent.py (7)
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: When defining an Agent in praisonaiagents/agent/ (Python), always provide parameters for name, role, goal, backstory, LLM selection, self-reflection (with min/max iterations), optional tools, and guardrail logic (function or string) with a retry limit.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: When implementing tools in praisonaiagents/tools/ (Python), use either the @tool decorator for simple function-based tools or subclass BaseTool for more complex tools.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.cursorrules:0-0
Timestamp: 2025-06-24T05:57:49.377Z
Learning: The PraisonAIAgents class (in src/agents/agents.ts) is responsible for managing multiple agents, tasks, memory, process type, and acts as the orchestrator for agent interactions. It should accept configuration options for verbosity, completion checking, retries, process type, memory, and embedding.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-agents/CLAUDE.md:0-0
Timestamp: 2025-06-24T05:58:06.506Z
Learning: Multi-agent workflows in praisonaiagents/agents/ (Python) should use PraisonAIAgents to orchestrate agents and tasks, supporting sequential, hierarchical, and parallel processes, with optional manager agents for hierarchical flows.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.windsurfrules:0-0
Timestamp: 2025-06-24T05:58:21.674Z
Learning: In the TypeScript/Node.js version of PraisonAI Agents, all references to LLM or litellm should be replaced with aisdk usage for large language model calls. The LLM class in src/llm/llm.ts should wrap aisdk.generateText and provide a response method for agent and task usage.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.windsurfrules:0-0
Timestamp: 2025-06-24T05:58:21.674Z
Learning: The PraisonAIAgents class should manage multiple agents, tasks, memory, process type, and other configurations, acting as the orchestrator for agent and task interactions. It should support process types such as sequential, workflow, and hierarchical.
Learnt from: CR
PR: MervinPraison/PraisonAI#0
File: src/praisonai-ts/.cursorrules:0-0
Timestamp: 2025-06-24T05:57:49.377Z
Learning: In the TypeScript/Node.js version of PraisonAI Agents, all references to LLM or litellm should be replaced with aisdk usage for large language model calls. The LLM class in src/llm/llm.ts should wrap aisdk.generateText and provide a response method that returns a Promise<string>.
🧬 Code Graph Analysis (4)
examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py (2)
src/praisonai-agents/praisonaiagents/knowledge/knowledge.py (1)
  • markdown (167-168)
src/praisonai-agents/praisonaiagents/llm/llm.py (1)
  • response (1525-1630)
examples/python/tools/exa-tool/legaliaai_minicourt.py (2)
src/praisonai-agents/praisonaiagents/knowledge/knowledge.py (1)
  • markdown (167-168)
src/praisonai-agents/praisonaiagents/llm/llm.py (1)
  • response (1525-1630)
examples/python/tools/exa-tool/intelligent_cognitive_agent.py (1)
src/praisonai-agents/praisonaiagents/llm/llm.py (1)
  • response (1525-1630)
examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py (3)
src/praisonai/praisonai.rb (1)
  • install (12-14)
src/praisonai-agents/praisonaiagents/main.py (1)
  • json (409-412)
src/praisonai-ts/tests/__mocks__/openai.ts (1)
  • OpenAI (29-52)
🪛 Flake8 (7.2.0)
examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py

[error] 30-30: module level import not at top of file

(E402)


[error] 45-45: module level import not at top of file

(E402)


[error] 46-46: module level import not at top of file

(E402)


[error] 48-48: expected 2 blank lines, found 1

(E302)


[error] 53-53: expected 2 blank lines after class or function definition, found 1

(E305)


[error] 61-61: expected 2 blank lines, found 1

(E302)


[error] 64-64: expected 2 blank lines after class or function definition, found 1

(E305)

examples/python/tools/exa-tool/chile_government_services_assistant_.py

[error] 29-29: module level import not at top of file

(E402)


[error] 30-30: module level import not at top of file

(E402)


[error] 31-31: module level import not at top of file

(E402)


[error] 33-33: expected 2 blank lines, found 1

(E302)


[error] 40-40: expected 2 blank lines, found 1

(E302)


[error] 52-52: expected 2 blank lines, found 1

(E302)


[error] 112-112: expected 2 blank lines after class or function definition, found 1

(E305)


[error] 114-114: undefined name 'FIRECRAWL_INSTRUCTION'

(F821)


[error] 115-115: undefined name 'FIRECRAWL_TEMPLATE'

(F821)

examples/python/tools/exa-tool/legaliaai_minicourt.py

[error] 40-40: module level import not at top of file

(E402)


[error] 110-110: expected 2 blank lines, found 1

(E302)


[error] 126-126: expected 2 blank lines, found 1

(E302)


[error] 135-135: expected 2 blank lines after class or function definition, found 1

(E305)


[error] 141-141: f-string is missing placeholders

(F541)


[error] 173-173: f-string is missing placeholders

(F541)


[error] 187-187: f-string is missing placeholders

(F541)

examples/python/tools/exa-tool/memorypal_search_agent.py

[error] 29-29: module level import not at top of file

(E402)


[error] 31-31: expected 2 blank lines, found 1

(E302)


[error] 44-44: expected 2 blank lines after class or function definition, found 1

(E305)


[error] 44-44: module level import not at top of file

(E402)


[error] 73-73: module level import not at top of file

(E402)

examples/python/tools/exa-tool/intelligent_cognitive_agent.py

[error] 29-29: module level import not at top of file

(E402)


[error] 30-30: module level import not at top of file

(E402)


[error] 34-34: expected 2 blank lines, found 1

(E302)


[error] 37-37: expected 1 blank line, found 0

(E301)


[error] 41-41: expected 2 blank lines after class or function definition, found 1

(E305)


[error] 54-54: expected 2 blank lines, found 1

(E302)


[error] 62-62: expected 2 blank lines after class or function definition, found 1

(E305)

examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py

[error] 24-24: SyntaxError: invalid syntax

(E999)

🪛 Ruff (0.11.9)
examples/python/tools/exa-tool/chile_government_services_assistant_.py

114-114: Undefined name FIRECRAWL_INSTRUCTION

(F821)


115-115: Undefined name FIRECRAWL_TEMPLATE

(F821)

examples/python/tools/exa-tool/legaliaai_minicourt.py

141-141: f-string without any placeholders

Remove extraneous f prefix

(F541)


173-173: f-string without any placeholders

Remove extraneous f prefix

(F541)


187-187: f-string without any placeholders

Remove extraneous f prefix

(F541)

examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py

24-24: SyntaxError: Expected a statement


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons

🪛 Pylint (3.3.7)
examples/python/tools/exa-tool/chile_government_services_assistant_.py

[refactor] 77-87: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)


[refactor] 52-52: Too few public methods (1/2)

(R0903)


[error] 114-114: Undefined variable 'FIRECRAWL_INSTRUCTION'

(E0602)


[error] 115-115: Undefined variable 'FIRECRAWL_TEMPLATE'

(E0602)

examples/python/tools/exa-tool/intelligent_cognitive_agent.py

[refactor] 34-34: Too few public methods (1/2)

(R0903)

examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py

[error] 24-24: Parsing failed: 'invalid syntax (pocky_cybersecurity_poc_agent, line 24)'

(E0001)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test-core (3.11)
  • GitHub Check: quick-test

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace the placeholder API key with proper configuration.

The hardcoded placeholder API key will cause authentication failures at runtime.

-    os.environ['OPENAI_API_KEY'] = "Enter your api key"
+    os.environ['OPENAI_API_KEY'] = api_key

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/legaliaai_minicourt.py at line 34, replace the
hardcoded placeholder API key string with a secure method to load the API key,
such as reading it from an environment variable or a configuration file. This
will prevent authentication failures by ensuring the actual API key is used at
runtime instead of a fixed placeholder.

Comment on lines +25 to +26
OPENAI_API_KEY = "Enter your api key here" # <-- Replace with your key
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace hardcoded API key with proper configuration.

The hardcoded placeholder will cause authentication failures.

-OPENAI_API_KEY = "Enter your api key here"  # <-- Replace with your key
-os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
+api_key = os.getenv('OPENAI_API_KEY') or input("Enter your OpenAI API key: ").strip()
+os.environ["OPENAI_API_KEY"] = api_key
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
OPENAI_API_KEY = "Enter your api key here" # <-- Replace with your key
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
api_key = os.getenv("OPENAI_API_KEY") or input("Enter your OpenAI API key: ").strip()
os.environ["OPENAI_API_KEY"] = api_key
🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py around lines
25 to 26, the OpenAI API key is hardcoded as a placeholder string, which will
cause authentication failures. Remove the hardcoded key and instead load the API
key from a secure configuration source such as environment variables or a
configuration file. Then assign this value to os.environ["OPENAI_API_KEY"] to
ensure proper authentication without exposing sensitive information in the code.

Comment on lines +48 to +52
def ask_agent(question):
# Use the .chat() method for the public praisonaiagents package
response = praison_agent.chat(question)
display(Markdown(f"**Praison AI:** {response}"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling to the chat function.

The chat function should handle potential API errors gracefully to prevent crashes in the interactive interface.

 def ask_agent(question):
-    # Use the .chat() method for the public praisonaiagents package
-    response = praison_agent.chat(question)
-    display(Markdown(f"**Praison AI:** {response}"))
+    try:
+        # Use the .chat() method for the public praisonaiagents package
+        response = praison_agent.chat(question)
+        display(Markdown(f"**Praison AI:** {response}"))
+    except Exception as e:
+        display(Markdown(f"**Error:** {str(e)}"))
🧰 Tools
🪛 Flake8 (7.2.0)

[error] 48-48: expected 2 blank lines, found 1

(E302)

🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/praison_ai_real_estate_chatbot.py around lines
48 to 52, the ask_agent function calls praison_agent.chat without error
handling, which can cause crashes if the API fails. Wrap the call to
praison_agent.chat in a try-except block to catch exceptions, and handle errors
gracefully by displaying an appropriate error message instead of letting the
program crash.

# Install Dependencies
"""

!pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the critical syntax error.

The line contains Jupyter notebook cell magic which is invalid Python syntax and will prevent the script from running.

-!pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4
+# Installation command (run this in your terminal or notebook):
+# pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
!pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4
# Installation command (run this in your terminal or notebook):
# pip install praisonaiagents exa-py python-dotenv requests beautifulsoup4
🧰 Tools
🪛 Flake8 (7.2.0)

[error] 24-24: SyntaxError: invalid syntax

(E999)

🪛 Ruff (0.11.9)

24-24: SyntaxError: Expected a statement


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons


24-24: SyntaxError: Simple statements must be separated by newlines or semicolons

🪛 Pylint (3.3.7)

[error] 24-24: Parsing failed: 'invalid syntax (pocky_cybersecurity_poc_agent, line 24)'

(E0001)

🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py at line 24,
remove the Jupyter notebook cell magic prefix "!pip" since it is invalid Python
syntax. Replace it with a standard Python package installation approach, such as
running the pip install command outside the script or using subprocess within
the script if installation is necessary at runtime.

Comment on lines +31 to +33
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace placeholder API keys with proper configuration.

The hardcoded placeholder values will cause authentication failures.

-os.environ["EXA_API_KEY"] = "your api key"
-os.environ["OPENAI_API_KEY"] = "your api key"
+os.environ["EXA_API_KEY"] = os.getenv("EXA_API_KEY") or input("Enter your Exa API key: ").strip()
+os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") or input("Enter your OpenAI API key: ").strip()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
os.environ["EXA_API_KEY"] = os.getenv("EXA_API_KEY") or input("Enter your Exa API key: ").strip()
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") or input("Enter your OpenAI API key: ").strip()
os.environ["OPENAI_BASE_URL"] = "https://api.openai.com/v1" # Optional, for custom OpenAI endpoints
🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/pocky_cybersecurity_poc_agent.py around lines
31 to 33, the environment variables for API keys are set to hardcoded
placeholder strings. Replace these placeholder values with actual API keys
retrieved securely from configuration files, environment variables, or secret
management systems to avoid authentication failures.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security risk: Remove hardcoded API key placeholder.

The hardcoded placeholder API key should be removed to prevent accidental exposure of real credentials.

Apply this diff to use proper environment variable handling:

-os.environ['OPENAI_API_KEY'] = 'Enter your api key'  # <-- Replace with your actual OpenAI or OpenRouter API key
+# Ensure your OPENAI_API_KEY environment variable is set
+if not os.environ.get('OPENAI_API_KEY'):
+    raise ValueError("OPENAI_API_KEY environment variable must be set")
🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/intelligent_cognitive_agent.py at line 25,
remove the hardcoded placeholder API key assignment to os.environ. Instead,
ensure the code reads the API key from the environment variables set outside the
code, such as by using os.getenv('OPENAI_API_KEY'), to avoid embedding sensitive
information directly in the source code.

Comment on lines +22 to +30
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix import organization and formatting issues.

The imports should be organized at the top of the file, and proper spacing should be maintained according to PEP 8.

Apply this diff to fix the import organization:

-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
+import os
+import re
+from praisonaiagents import Agent
+
+
+# Ensure your OPENAI_API_KEY environment variable is set
+if not os.environ.get('OPENAI_API_KEY'):
+    raise ValueError("OPENAI_API_KEY environment variable must be set")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
import os
import re
from praisonaiagents import Agent
# Ensure your OPENAI_API_KEY environment variable is set
if not os.environ.get('OPENAI_API_KEY'):
raise ValueError("OPENAI_API_KEY environment variable must be set")
🧰 Tools
🪛 Flake8 (7.2.0)

[error] 29-29: module level import not at top of file

(E402)


[error] 30-30: module level import not at top of file

(E402)

🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/intelligent_cognitive_agent.py around lines 22
to 30, the import statements are not properly organized and spaced. Move all
import statements to the top of the file before any other code, group standard
library imports separately from third-party imports, and ensure there is a blank
line between different import groups to comply with PEP 8 formatting guidelines.

Comment on lines +64 to +70
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,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance Agent configuration with comprehensive PraisonAI parameters.

Based on the retrieved learnings, the Agent should include more comprehensive configuration parameters for better functionality.

Apply this diff to improve the agent configuration:

-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,
-)
+agent = Agent(
+    name="Cognitive Assistant",
+    role="Multi-domain cognitive advisor",
+    goal="Provide comprehensive cognitive assistance by leveraging specialist tools",
+    backstory="""You are an intelligent cognitive assistant with access to multiple 
+    specialist domains including decision making, problem solving, systems thinking, 
+    psychology, strategy, learning, efficiency, and motivation. You carefully select 
+    and combine insights from the most relevant specialists to provide comprehensive answers.""",
+    instructions="""
+        You are a cognitive assistant with access to specialist tools covering:
+        - Decision making and risk assessment
+        - Problem solving and innovation
+        - Systems thinking and complexity analysis
+        - Psychology and bias awareness
+        - Strategy and competition
+        - Learning and communication
+        - Efficiency and process optimization
+        - Motivation and human factors
+        
+        Use the most relevant tool(s) to answer the user's query, and synthesize 
+        insights from multiple specialists when appropriate.
+    """,
+    tools=tools,
+    max_iter=3,
+    verbose=True,
+)
🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/intelligent_cognitive_agent.py around lines 64
to 70, the Agent initialization lacks comprehensive configuration parameters for
PraisonAI. Enhance the Agent constructor by adding additional relevant
parameters such as model settings, memory configuration, or any other
recommended PraisonAI options to improve its functionality and responsiveness.
Review PraisonAI documentation or examples to identify and include these
parameters appropriately within the Agent initialization.

Comment on lines +34 to +39
class SpecialistAgent:
def __init__(self, name):
self.name = name
def run(self, query):
return f"{self.name} specialist response to: {query}"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance the SpecialistAgent class with proper documentation and structure.

The current implementation is too simplistic and lacks proper documentation. Consider making it more aligned with PraisonAI patterns.

Apply this diff to improve the class:

-class SpecialistAgent:
-    def __init__(self, name):
-        self.name = name
-    def run(self, query):
-        return f"{self.name} specialist response to: {query}"
+class SpecialistAgent:
+    """A specialist agent representing a specific cognitive domain."""
+    
+    def __init__(self, name: str, domain: str = ""):
+        self.name = name
+        self.domain = domain or name.replace('_', ' ').title()
+    
+    def run(self, query: str) -> str:
+        """Process a query within this specialist's domain."""
+        return f"{self.domain} specialist analysis: {query}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class SpecialistAgent:
def __init__(self, name):
self.name = name
def run(self, query):
return f"{self.name} specialist response to: {query}"
class SpecialistAgent:
"""A specialist agent representing a specific cognitive domain."""
def __init__(self, name: str, domain: str = ""):
self.name = name
self.domain = domain or name.replace('_', ' ').title()
def run(self, query: str) -> str:
"""Process a query within this specialist's domain."""
return f"{self.domain} specialist analysis: {query}"
🧰 Tools
🪛 Flake8 (7.2.0)

[error] 34-34: expected 2 blank lines, found 1

(E302)


[error] 37-37: expected 1 blank line, found 0

(E301)

🪛 Pylint (3.3.7)

[refactor] 34-34: Too few public methods (1/2)

(R0903)

🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/intelligent_cognitive_agent.py around lines 34
to 39, the SpecialistAgent class lacks proper documentation and structure. Add a
class-level docstring explaining the purpose of the class, and include
method-level docstrings for __init__ and run methods describing their parameters
and return values. Refactor the class to follow PraisonAI patterns by ensuring
clear separation of concerns and possibly adding type hints for better clarity
and maintainability.

Comment on lines +54 to +61
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve tool creation to follow PraisonAI best practices.

The tool creation function should include proper documentation and error handling, and ideally use the @tool decorator pattern.

Based on the retrieved learnings about PraisonAI tool implementation, consider this improved approach:

-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
+def make_tool(agent: SpecialistAgent):
+    """Create a tool function from a specialist agent."""
+    def tool(query: str) -> str:
+        """Tool function that processes queries through the specialist agent."""
+        try:
+            return agent.run(query)
+        except Exception as e:
+            return f"Error in {agent.name}: {str(e)}"
+    
+    # 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
+    tool.__doc__ = f"Specialist tool for {agent.domain}"
+    return tool
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
def make_tool(agent: SpecialistAgent):
"""Create a tool function from a specialist agent."""
def tool(query: str) -> str:
"""Tool function that processes queries through the specialist agent."""
try:
return agent.run(query)
except Exception as e:
return f"Error in {agent.name}: {str(e)}"
# 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
tool.__doc__ = f"Specialist tool for {agent.domain}"
return tool
🧰 Tools
🪛 Flake8 (7.2.0)

[error] 54-54: expected 2 blank lines, found 1

(E302)

🤖 Prompt for AI Agents
In examples/python/tools/exa-tool/intelligent_cognitive_agent.py around lines 54
to 61, improve the make_tool function by adding a proper docstring explaining
its purpose and usage, wrapping the inner tool function with a try-except block
to handle and log errors gracefully, and applying the @tool decorator from
PraisonAI if available to ensure compliance with best practices. This will
enhance maintainability, error resilience, and integration with PraisonAI's
tooling system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants