Skip to main content
You can also check this cookbook in colab here
CAMEL HomepageJoin Discord
Star us on GitHub, join our Discord, or follow us on X
This notebook provides a comprehensive guide to generating user queries and structured tool call data using CAMEL’s ChatAgent framework. By utilizing real tools and the Hermes JSON format for function calls, the tutorial demonstrates a structured approach to scalable and flexible data generation. In this notebook, you’ll explore:
  • CAMEL’s ChatAgent Framework: A multi-agent system for generating human-like queries and structured tool call data, leveraging its modular and adaptable design.
  • Hermes Function Calling Format: A standardized JSON-based format for encoding function calls, ensuring consistency and interoperability in structured data outputs.
  • OpenAI API Integration: Enabling advanced natural language understanding and generation for crafting user queries and processing tool responses.
  • Toolkits Integration: Leveraging tools such as MathToolkit, SearchToolkit, and others to provide diverse functionalities for realistic scenarios.
  • Automated Data Generation: End-to-end pipeline for generating tool-specific user queries, structuring their outputs, and saving them as JSON files.

Installation

Ensure you have CAMEL AI and desired dependencies installed in your Python environment:

Step 1: Import Required Libraries and Modules

Start by importing necessary libraries and modules.
Alternatively, if running on Colab, you could save your API keys and tokens as Colab Secrets, and use them across notebooks. To do so, comment out the above manual API key prompt code block(s), and uncomment the following codeblock. ⚠️ Don’t forget granting access to the API key you would be using to the current notebook.

Step 2: Define Function to Generate User Queries

This function leverages specific tools to generate human-like queries. We’ll set up a ChatAgent to create relevant, tool-specific user queries.

Step 3: Define Function to Generate Structured Tool Call Data

This function will structure tool call data based on user queries by leveraging each selected tool.

Step 4: Initialize Toolkits and Define Tools List

We’ll set up toolkits we want to be used

Step 5: Generate Data and Save to JSON

We now loop through each tool, generate queries, create tool call data, and save it all in JSON format.

Step 6: Verify the JSON Output

Open the generated JSON file and verify that the tool call data has been saved correctly.

Summary

In this tutorial, you learned how to generate user queries and structure tool call data by leveraging multiple tools with the camel library. This setup enables scalable and flexible data generation for various toolkits and tasks.
CAMEL HomepageJoin Discord
Star us on GitHub, join our Discord, or follow us on X