Skip to content

cookbook: add data analysis agent using DataCommonsToolkit#3987

Open
lovek629 wants to merge 2 commits intocamel-ai:masterfrom
lovek629:add-data-analysis-agent-cookbook
Open

cookbook: add data analysis agent using DataCommonsToolkit#3987
lovek629 wants to merge 2 commits intocamel-ai:masterfrom
lovek629:add-data-analysis-agent-cookbook

Conversation

@lovek629
Copy link
Copy Markdown

@lovek629 lovek629 commented Apr 6, 2026

Related Issue

Closes #2847

Description

Adds a new cookbook notebook demonstrating a Data Analysis Agent
using CAMEL's built-in data toolkits.

The notebook covers:

  • Querying real-world statistical data using DataCommonsToolkit (no API key needed)
  • Population, time-series and comparative analysis queries
  • Multi-toolkit agent combining DataCommonsToolkit + SearchToolkit
  • Colab badge for easy one-click execution

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Checklist

  • I have read and agree to the AI-Generated Code Policy (required)
  • I have linked this PR to an issue (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and run uv lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed
  • I have added examples if this is a new feature

Signed-off-by: Progressive-engg <lov.kumari55@gmail.com>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

Walkthrough

A new Jupyter notebook is added to the cookbook demonstrating end-to-end usage of a CAMEL-based data analysis agent. The notebook showcases single and multi-toolkit configurations using DataCommonsToolkit and SearchToolkit, executing example queries about population demographics, emissions trends, and comparative economic indicators.

Changes

Cohort / File(s) Summary
Data Analysis Agent Cookbook
cookbook/data_analysis_agent.ipynb
New Jupyter notebook demonstrating CAMEL agent construction with data analysis tools, including single-toolkit agent examples (population, emissions, income queries) and a multi-toolkit agent combining DataCommonsToolkit and SearchToolkit for cross-source analysis.

Poem

🐰 A cookbook for data so bright,
With agents that analyze with delight,
From emissions to income they swiftly compare,
Across toolkits, searching everywhere! 📊✨

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: adding a new cookbook notebook for a data analysis agent using DataCommonsToolkit.
Description check ✅ Passed The description is well-related to the changeset, providing context about the notebook's purpose, coverage, and features including DataCommonsToolkit queries and multi-toolkit agent examples.
Linked Issues check ✅ Passed The PR successfully addresses issue #2847 by creating a cookbook notebook that leverages CAMEL's data analysis toolkits (DataCommonsToolkit and SearchToolkit) as a practical use case for a data analysis agent.
Out of Scope Changes check ✅ Passed All changes are in-scope: the PR adds a single Jupyter notebook demonstrating data analysis workflows as requested in the linked issue, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Ruff (0.15.9)
cookbook/data_analysis_agent.ipynb

Unexpected end of JSON input


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@lovek629
Copy link
Copy Markdown
Author

@coderabbitai pls review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

@lovek629 Sure! I'll start reviewing the PR right away.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cookbook/data_analysis_agent.ipynb`:
- Around line 66-77: Replace the hard-coded placeholder in
os.environ["OPENAI_API_KEY"] ("your_openai_api_key_here") with a secure input
pattern: check for an existing environment variable first and if missing prompt
the user using getpass (e.g., import getpass and call getpass("Enter your OpenAI
API key: ")), and add a clear warning comment above the assignment that users
must provide a valid key; update the notebook cells that rely on OPENAI_API_KEY
to assume this secure-loading behavior (refer to the
os.environ["OPENAI_API_KEY"] assignment and the commented getpass snippet to
locate where to change).
- Around line 15-26: The notebook overview and prerequisites incorrectly claim
demonstration of OpenBBToolkit and require an OpenBB token despite only using
DataCommonsToolkit and SearchToolkit; remove all mentions of "OpenBBToolkit" and
the OpenBB token bullet from the overview/prerequisites text, and optionally
rephrase the summary to mention OpenBBToolkit only as a "next step" or optional
extension so the documented prerequisites and overview match the actual use of
DataCommonsToolkit and SearchToolkit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f278cf25-3fef-4037-b20d-4efaf5d5bcbf

📥 Commits

Reviewing files that changed from the base of the PR and between 1821e4c and 6de394c.

📒 Files selected for processing (1)
  • cookbook/data_analysis_agent.ipynb

Comment on lines +15 to +26
"This cookbook demonstrates how to build a **Data Analysis Agent** using CAMEL's built-in data toolkits. We combine multiple data sources into a single intelligent agent that can:\n",
"\n",
"- 🌍 Query real-world statistical data using `DataCommonsToolkit`\n",
"- 📈 Retrieve financial market data using `OpenBBToolkit`\n",
"- 🤖 Analyse and answer natural language questions using `ChatAgent`\n",
"\n",
"This is a practical end-to-end example of how CAMEL's multi-toolkit agent approach enables powerful data-driven insights with minimal code.\n",
"\n",
"## Prerequisites\n",
"\n",
"- OpenAI API key (for the language model)\n",
"- OpenBB token (free at https://my.openbb.co) — optional, only for financial data section\n"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistency between overview and actual content.

The overview claims to demonstrate OpenBBToolkit (line 18) and lists an OpenBB token as a prerequisite (line 26), but the notebook only uses DataCommonsToolkit and SearchToolkit. The summary section correctly lists OpenBBToolkit as a "next step" rather than demonstrated content.

Remove the OpenBBToolkit references from the overview and prerequisites to align with the actual notebook content.

📝 Proposed fix to align overview with content
-This cookbook demonstrates how to build a **Data Analysis Agent** using CAMEL's built-in data toolkits. We combine multiple data sources into a single intelligent agent that can:\n",
+This cookbook demonstrates how to build a **Data Analysis Agent** using CAMEL's built-in data toolkits. We combine multiple data sources into a single intelligent agent that can:\n",
 \n",
 - 🌍 Query real-world statistical data using `DataCommonsToolkit`\n",
-- 📈 Retrieve financial market data using `OpenBBToolkit`\n",
+- 🔍 Search the web for current information using `SearchToolkit`\n",
 - 🤖 Analyse and answer natural language questions using `ChatAgent`\n",
 \n",
 This is a practical end-to-end example of how CAMEL's multi-toolkit agent approach enables powerful data-driven insights with minimal code.\n",
 \n",
 ## Prerequisites\n",
 \n",
-- OpenAI API key (for the language model)\n",
-- OpenBB token (free at https://my.openbb.co) — optional, only for financial data section\n"
+- OpenAI API key (for the language model)\n"
📝 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
"This cookbook demonstrates how to build a **Data Analysis Agent** using CAMEL's built-in data toolkits. We combine multiple data sources into a single intelligent agent that can:\n",
"\n",
"- 🌍 Query real-world statistical data using `DataCommonsToolkit`\n",
"- 📈 Retrieve financial market data using `OpenBBToolkit`\n",
"- 🤖 Analyse and answer natural language questions using `ChatAgent`\n",
"\n",
"This is a practical end-to-end example of how CAMEL's multi-toolkit agent approach enables powerful data-driven insights with minimal code.\n",
"\n",
"## Prerequisites\n",
"\n",
"- OpenAI API key (for the language model)\n",
"- OpenBB token (free at https://my.openbb.co) — optional, only for financial data section\n"
"This cookbook demonstrates how to build a **Data Analysis Agent** using CAMEL's built-in data toolkits. We combine multiple data sources into a single intelligent agent that can:\n",
"\n",
"- 🌍 Query real-world statistical data using `DataCommonsToolkit`\n",
"- 🔍 Search the web for current information using `SearchToolkit`\n",
"- 🤖 Analyse and answer natural language questions using `ChatAgent`\n",
"\n",
"This is a practical end-to-end example of how CAMEL's multi-toolkit agent approach enables powerful data-driven insights with minimal code.\n",
"\n",
"## Prerequisites\n",
"\n",
"- OpenAI API key (for the language model)\n"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cookbook/data_analysis_agent.ipynb` around lines 15 - 26, The notebook
overview and prerequisites incorrectly claim demonstration of OpenBBToolkit and
require an OpenBB token despite only using DataCommonsToolkit and SearchToolkit;
remove all mentions of "OpenBBToolkit" and the OpenBB token bullet from the
overview/prerequisites text, and optionally rephrase the summary to mention
OpenBBToolkit only as a "next step" or optional extension so the documented
prerequisites and overview match the actual use of DataCommonsToolkit and
SearchToolkit.

Comment on lines +66 to +77
"import os\n",
"\n",
"# Set your OpenAI API key\n",
"os.environ[\"OPENAI_API_KEY\"] = \"your_openai_api_key_here\"\n",
"\n",
"# Optional: Set your OpenBB token for financial data\n",
"# os.environ[\"OPENBB_TOKEN\"] = \"your_openbb_token_here\"\n",
"\n",
"# Or load from environment directly:\n",
"# from getpass import getpass\n",
"# os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: \")"
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Hard-coded API key placeholder will cause runtime failure.

Line 69 sets the API key to a placeholder string "your_openai_api_key_here", which will cause authentication errors when users execute subsequent cells. This also demonstrates insecure credential handling.

Consider using getpass as the default approach, or at minimum add a clear warning comment above line 69 instructing users to replace the placeholder before execution.

🔐 Proposed fix to use getpass by default
 import os\n",
 \n",
-# Set your OpenAI API key\n",
-os.environ[\"OPENAI_API_KEY\"] = \"your_openai_api_key_here\"\n",
+# Set your OpenAI API key using getpass for security\n",
+from getpass import getpass\n",
+os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: \")\n",
 \n",
 # Optional: Set your OpenBB token for financial data\n",
 # os.environ[\"OPENBB_TOKEN\"] = \"your_openbb_token_here\"\n",
-\n",
-# Or load from environment directly:\n",
-# from getpass import getpass\n",
-# os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI 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
"import os\n",
"\n",
"# Set your OpenAI API key\n",
"os.environ[\"OPENAI_API_KEY\"] = \"your_openai_api_key_here\"\n",
"\n",
"# Optional: Set your OpenBB token for financial data\n",
"# os.environ[\"OPENBB_TOKEN\"] = \"your_openbb_token_here\"\n",
"\n",
"# Or load from environment directly:\n",
"# from getpass import getpass\n",
"# os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: \")"
]
"import os\n",
"\n",
"# Set your OpenAI API key using getpass for security\n",
"from getpass import getpass\n",
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: \")\n",
"\n",
"# Optional: Set your OpenBB token for financial data\n",
"# os.environ[\"OPENBB_TOKEN\"] = \"your_openbb_token_here\"\n",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cookbook/data_analysis_agent.ipynb` around lines 66 - 77, Replace the
hard-coded placeholder in os.environ["OPENAI_API_KEY"]
("your_openai_api_key_here") with a secure input pattern: check for an existing
environment variable first and if missing prompt the user using getpass (e.g.,
import getpass and call getpass("Enter your OpenAI API key: ")), and add a clear
warning comment above the assignment that users must provide a valid key; update
the notebook cells that rely on OPENAI_API_KEY to assume this secure-loading
behavior (refer to the os.environ["OPENAI_API_KEY"] assignment and the commented
getpass snippet to locate where to change).

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.

[Feature Request] data analyse agent and cookbook

2 participants