cookbook: add data analysis agent using DataCommonsToolkit#3987
cookbook: add data analysis agent using DataCommonsToolkit#3987lovek629 wants to merge 2 commits intocamel-ai:masterfrom
Conversation
Signed-off-by: Progressive-engg <lov.kumari55@gmail.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
WalkthroughA 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
Poem
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.ipynbUnexpected 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. Comment |
|
@coderabbitai pls review |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
cookbook/data_analysis_agent.ipynb
| "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" |
There was a problem hiding this comment.
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.
| "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.
| "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: \")" | ||
| ] |
There was a problem hiding this comment.
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.
| "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).
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:
DataCommonsToolkit(no API key needed)DataCommonsToolkit+SearchToolkitWhat is the purpose of this pull request?
Checklist
pyproject.tomland runuv lock