Tutorial
CAMEL-AI x Wolfram|Alpha: Smarter Agents Through Powerful Computation
How the integration of CAMEL-AI’s multi-agent framework and Wolfram|Alpha’s computation engine is powering the next wave of intelligent AI agents.
Tutorial
How the integration of CAMEL-AI’s multi-agent framework and Wolfram|Alpha’s computation engine is powering the next wave of intelligent AI agents.
In today's rapidly evolving artificial intelligence landscape, multi-agent systems are redefining the boundaries of AI. CAMEL-AI, as the world's first multi-agent framework, is dedicated to finding the scaling laws of agents, while Wolfram|Alpha, as the world's leading computational knowledge engine, provides powerful mathematical computing and knowledge query capabilities for AI systems. Today, we are excited to announce a deep partnership between CAMEL and Wolfram|Alpha, which will bring enhanced computational intelligence capabilities to multi-agent systems.
CAMEL-AI is an open-source community dedicated to finding the scaling laws of agents. CAMEL (https://github.com/camel-ai) is a native multi-agent framework launched by CAMEL-AI. As the world's first multi-agent framework, CAMEL believes that studying intelligent agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks.
🧬 Evolvability
📈 Scalability
💾 Statefulness
📖 Code-as-Prompt Every line of code and comment serves as a prompt for agents. Code should be written clearly and readably, ensuring both humans and agents can interpret it effectively.
The advent of Wolfram|Alpha has defined a new paradigm for accessing knowledge and answers—not through web searches, but through dynamic computation based on vast built-in data, algorithms, and methods. As stated on the Wolfram|Alpha official website, its long-term goal is to make all systematic knowledge immediately computable and accessible to everyone.
Wolfram|Alpha's implementation relies on two key technological breakthroughs:
1. The Wolfram Language
2. A New Kind of Science (NKS) Paradigm
Wolfram|Alpha provides a complete API ecosystem to meet different application scenarios:
Through our partnership, CAMEL now integrates the powerful WolframAlphaToolkit, providing three main computational capabilities for multi-agent systems.
def query_wolfram_alpha(self, query: str) -> str:
"""Query Wolfram|Alpha and return simple answer
Args:
query (str): Query to send to Wolfram Alpha
Returns:
str: Simple answer returned by Wolfram Alpha
"""
import wolframalpha
WOLFRAMALPHA_APP_ID = os.environ.get("WOLFRAMALPHA_APP_ID", "")
try:
client = wolframalpha.Client(WOLFRAMALPHA_APP_ID)
res = client.query(query)
except Exception as e:
return f"Wolfram Alpha wasn't able to answer it. Error: {e}"
parsed_result = self._parse_wolfram_result(res)
return parsed_result["final_answer"]
Technical Features:
wolframalpha
Python library@api_keys_required([
(None, "WOLFRAMALPHA_APP_ID"),
])
@dependencies_required("wolframalpha")
def query_wolfram_alpha_step_by_step(self, query: str) -> Dict[str, Any]:
"""Query Wolfram|Alpha and return detailed results with step-by-step solutions
Returns:
Dict[str, Any]: Dictionary containing detailed information including step-by-step solutions
{
"query": "original query",
"pod_info": [
{
"title": "pod title",
"description": "description text",
"image_url": "image URL"
}
],
"final_answer": "final answer",
"steps": {
"step1": "first step",
"step2": "second step",
...
}
}
"""
Technical Features:
def query_wolfram_alpha_llm(self, query: str) -> str:
"""Send query to Wolfram|Alpha LLM API
Uses specialized LLM API endpoint: https://www.wolframalpha.com/api/v1/llm-api
"""
WOLFRAMALPHA_APP_ID = os.environ.get("WOLFRAMALPHA_APP_ID", "")
try:
url = "https://www.wolframalpha.com/api/v1/llm-api"
params = {
"input": query,
"appid": WOLFRAMALPHA_APP_ID,
"format": "plaintext",
}
response = requests.get(url, params=params)
response.raise_for_status()
return response.text
except Exception as e:
return f"Wolfram Alpha wasn't able to answer it. Error: {e}"
Technical Features:
To start using CAMEL's Wolfram|Alpha integration, you need:
pip install 'camel-ai[all]'
export WOLFRAMALPHA_APP_ID=your_api_key_here
Let's demonstrate through specific code examples how CAMEL agents utilize Wolfram|Alpha's three different query methods:
from camel.agents import ChatAgent
from camel.models import ModelFactory
from camel.toolkits import WolframAlphaToolkit
from camel.types import ModelPlatformType, ModelType
# Create model
model = ModelFactory.create(
model_platform=ModelPlatformType.DEFAULT,
model_type=ModelType.DEFAULT,
model_config_dict={"temperature": 0.0},
)
# Use basic query tool
tools = [WolframAlphaToolkit().query_wolfram_alpha]
agent = ChatAgent(
system_message="You're a helpful assistant",
model=model,
tools=tools,
)
response = agent.step("What's 5 densest elemental metals")
print(response.msgs[0].content)
print("\nTool calls:")
print(response.info['tool_calls'])
Output:
The five densest elemental metals are:
1. Hassium (Hs) - 41 g/cm³
2. Meitnerium (Mt) - 37.4 g/cm³
3. Bohrium (Bh) - 37.1 g/cm³
4. Seaborgium (Sg) - 35.3 g/cm³
5. Darmstadtium (Ds) - 34.8 g/cm³
Tool calls:
[ToolCallingRecord(tool_name='query_wolfram_alpha', args={'query': 'densest elemental metals'}, result='1 | hassium | 41 g/cm^3 | \n2 | meitnerium | 37.4 g/cm^3 | \n3 | bohrium | 37.1 g/cm^3 | \n4 | seaborgium | 35.3 g/cm^3 | \n5 | darmstadtium | 34.8 g/cm^3 |', tool_call_id='call_DNUzXQSQxAY3R71WMQXhKjBK')]
# Use detailed step-by-step analysis tool
tools = [WolframAlphaToolkit().query_wolfram_alpha_step_by_step]
agent = ChatAgent(
system_message="You're a helpful assistant",
model=model,
tools=tools,
)
response = agent.step("What's 5 densest elemental metals")
print(response.msgs[0].content)
Output (including detailed pod information):
The five densest elemental metals are:
1. **Hassium (Hs)** - 41 g/cm³
2. **Meitnerium (Mt)** - 37.4 g/cm³
3. **Bohrium (Bh)** - 37.1 g/cm³
4. **Seaborgium (Sg)** - 35.3 g/cm³
5. **Darmstadtium (Ds)** - 34.8 g/cm³
These values represent their densities at standard conditions.
Tool calls:
[ToolCallingRecord(tool_name='query_wolfram_alpha_step_by_step', args={'query': '5 densest elemental metals'}, result={
'query': '5 densest elemental metals',
'pod_info': [
{
'title': 'Input interpretation',
'description': '5 densest metallic elements | by mass density',
'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/...'
},
{
'title': 'Periodic table location',
'description': None,
'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/...'
},
{
'title': 'Basic elemental properties',
'description': '| atomic symbol | atomic number\nhassium | Hs | 108\nmeitnerium | Mt | 109\n...',
'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/...'
},
{
'title': 'Result',
'description': '1 | hassium | 41 g/cm^3 | \n2 | meitnerium | 37.4 g/cm^3 | ...',
'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/...'
}
],
'final_answer': '1 | hassium | 41 g/cm^3 | \n2 | meitnerium | 37.4 g/cm^3 | ...',
'steps': {}
})]
# Use LLM-optimized interface
tools = [WolframAlphaToolkit().query_wolfram_alpha_llm]
agent = ChatAgent(
system_message="You're a helpful assistant",
model=model,
tools=tools,
)
response = agent.step("What's 10 densest elemental metals")
print(response.msgs[0].content)
Output (LLM-optimized format):
The 10 densest elemental metals, measured by mass density, are:
1. **Hassium (Hs)** - 41 g/cm³
2. **Meitnerium (Mt)** - 37.4 g/cm³
3. **Bohrium (Bh)** - 37.1 g/cm³
4. **Seaborgium (Sg)** - 35.3 g/cm³
5. **Darmstadtium (Ds)** - 34.8 g/cm³
6. **Dubnium (Db)** - 29.3 g/cm³
7. **Roentgenium (Rg)** - 28.7 g/cm³
8. **Rutherfordium (Rf)** - 23.2 g/cm³
9. **Osmium (Os)** - 22.59 g/cm³
10. **Iridium (Ir)** - 22.56 g/cm³
Tool calls:
[ToolCallingRecord(tool_name='query_wolfram_alpha_llm', args={'query': '10 densest elemental metals'}, result='Query:\n"10 densest elemental metals"\n\nInput interpretation:\n10 densest metallic elements | by mass density\n\nBasic elemental properties:\natomic symbol | all | Bh | Db | Ds | Hs | Ir | Mt | Os | Rf | Rg | Sg\natomic number | median | 106.5\n | highest | 111 (roentgenium)\n | lowest | 76 (osmium)\n\nResult:\n1 | hassium | 41 g/cm^3 | \n2 | meitnerium | 37.4 g/cm^3 | \n3 | bohrium | 37.1 g/cm^3 | \n4 | seaborgium | 35.3 g/cm^3 | \n5 | darmstadtium | 34.8 g/cm^3 | \n6 | dubnium | 29.3 g/cm^3 | \n7 | roentgenium | 28.7 g/cm^3 | \n8 | rutherfordium | 23.2 g/cm^3 | \n9 | osmium | 22.59 g/cm^3 | \n10 | iridium | 22.56 g/cm^3 |')]
As highlighted in CAMEL-AI's latest blog, AI agents are undergoing an important transition from prompt engineering to end-to-end reinforcement learning. This transition has profound implications for the CAMEL and Wolfram|Alpha partnership.
Traditional prompt engineering approaches have the following limitations:
By integrating Wolfram|Alpha's computational capabilities, CAMEL agents can:
CAMEL-AI emphasizes that "environments are the missing data for agents." Wolfram|Alpha provides a unique computational environment for agents:
Traditional Data + Computational Environment = Complete Training Data for Agents
Characteristics of Computational Environment:
This partnership marks the beginning of deep collaboration between CAMEL and Wolfram|Alpha. We look forward to further cooperation in the following areas:
We hope that through the deep cooperation between CAMEL and Wolfram|Alpha, we can establish a new paradigm for computational intelligence.
Precision Assurance: Through Wolfram|Alpha's rigorous computational engine, CAMEL agents gain enhanced computational precision, significantly mitigating hallucination problems in mathematical and scientific calculations by large language models.
Knowledge Verifiability: Every computational result can be verified through independent mathematical verification, providing a reliable knowledge foundation for AI systems.
Interactive Learning: Agents not only rely on static training data but can also learn and evolve through real-time interaction with computational environments.
We believe that future AI development may have several important trends:
We deeply understand that realizing this vision requires the joint efforts of global developers, researchers, and innovators. As an open-source community, CAMEL-AI sincerely invites you to:
Let us work together to build a more intelligent, precise, and reliable AI future. In this future, every agent has powerful computational capabilities, every question can get precise answers, and every innovation is built on a solid scientific foundation.
Join our journey and explore the infinite possibilities of fusion between multi-agent systems and computational intelligence!
About CAMEL-AI CAMEL-AI is an open-source community dedicated to finding the scaling laws of agents. We believe that studying intelligent agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks.
About Wolfram|Alpha Wolfram|Alpha is the world's leading computational knowledge engine that computes answers from external data sources to respond to factual queries, providing powerful computational capabilities for various applications.
Contact Us
References