Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

fix: update with firecrawl and openai new version (#961)

Wendong-Fan44e7afe5405f
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index fad71d706..ba98fa9b2 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -27,7 +27,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
- placeholder: E.g., 0.2.0
+ placeholder: E.g., 0.2.1
validations:
required: true
diff --git a/README.md b/README.md
index 7d561b6a0..b394b85d6 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
-git clone -b v0.2.0 https://github.com/camel-ai/camel.git
+git clone -b v0.2.1 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
diff --git a/camel/__init__.py b/camel/__init__.py
index 7c0afeed1..15f5b34aa 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -12,7 +12,7 @@
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
-__version__ = '0.2.0'
+__version__ = '0.2.1'
__all__ = [
'__version__',
diff --git a/camel/loaders/firecrawl_reader.py b/camel/loaders/firecrawl_reader.py
index 5853ca24d..6bfe76959 100644
--- a/camel/loaders/firecrawl_reader.py
+++ b/camel/loaders/firecrawl_reader.py
@@ -49,7 +49,6 @@ class Firecrawl:
self,
url: str,
params: Optional[Dict[str, Any]] = None,
- wait_until_done: bool = True,
**kwargs: Any,
) -> Any:
r"""Crawl a URL and all accessible subpages. Customize the crawl by
@@ -60,14 +59,12 @@ class Firecrawl:
url (str): The URL to crawl.
params (Optional[Dict[str, Any]]): Additional parameters for the
crawl request. Defaults to `None`.
- wait_until_done (bool): Whether to wait until the crawl job is
- completed. Defaults to `True`.
**kwargs (Any): Additional keyword arguments, such as
- `poll_interval`, `idempotency_key`, etc.
+ `poll_interval`, `idempotency_key`.
Returns:
- Any: The list content of the URL if `wait_until_done` is True;
- otherwise, a string job ID.
+ Any: The crawl job ID or the crawl results if waiting until
+ completion.
Raises:
RuntimeError: If the crawling process fails.
@@ -78,13 +75,8 @@ class Firecrawl:
url=url,
params=params,
**kwargs,
- wait_until_done=wait_until_done,
- )
- return (
- crawl_response
- if wait_until_done
- else crawl_response.get("jobId")
)
+ return crawl_response
except Exception as e:
raise RuntimeError(f"Failed to crawl the URL: {e}")
@@ -103,7 +95,10 @@ class Firecrawl:
"""
try:
- crawl_result = self.app.crawl_url(url=url)
+ crawl_result = self.app.crawl_url(
+ url,
+ {'formats': ['markdown']},
+ )
if not isinstance(crawl_result, list):
raise ValueError("Unexpected response format")
markdown_contents = [
@@ -180,41 +175,14 @@ class Firecrawl:
data = self.app.scrape_url(
url,
{
- 'extractorOptions': {
- "mode": "llm-extraction",
- "extractionPrompt": "Based on the information on "
- "the page, extract the information from the schema.",
- 'extractionSchema': output_schema.model_json_schema(),
- },
- 'pageOptions': {'onlyMainContent': True},
+ 'formats': ['extract'],
+ 'extract': {'schema': output_schema.model_json_schema()},
},
)
- return data.get("llm_extraction", {})
+ return data.get("extract", {})
except Exception as e:
raise RuntimeError(f"Failed to perform structured scrape: {e}")
- def tidy_scrape(self, url: str) -> str:
- r"""Only return the main content of the page, excluding headers,
- navigation bars, footers, etc. in Markdown format.
-
- Args:
- url (str): The URL to read.
-
- Returns:
- str: The markdown content of the URL.
-
- Raises:
- RuntimeError: If the scrape process fails.
- """
-
- try:
- scrape_result = self.app.scrape_url(
- url, {'pageOptions': {'onlyMainContent': True}}
- )
- return scrape_result.get("markdown", "")
- except Exception as e:
- raise RuntimeError(f"Failed to perform tidy scrape: {e}")
-
def map_site(
self, url: str, params: Optional[Dict[str, Any]] = None
) -> list:
diff --git a/camel/models/mistral_model.py b/camel/models/mistral_model.py
index 0bd679e74..6d3c754a4 100644
--- a/camel/models/mistral_model.py
+++ b/camel/models/mistral_model.py
@@ -93,7 +93,7 @@ class MistralModel(BaseModelBackend):
"name": tool_call.function.name, # type: ignore[union-attr]
"arguments": tool_call.function.arguments, # type: ignore[union-attr]
},
- type=tool_call.TYPE, # type: ignore[union-attr]
+ type=tool_call.type, # type: ignore[union-attr]
)
for tool_call in response.choices[0].message.tool_calls
]
diff --git a/docs/conf.py b/docs/conf.py
index 40ae9b29a..ccfd1a0f6 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.2.0'
+release = '0.2.1'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/docs/cookbooks/agents_message.ipynb b/docs/cookbooks/agents_message.ipynb
index 607ca5d46..36407977f 100644
--- a/docs/cookbooks/agents_message.ipynb
+++ b/docs/cookbooks/agents_message.ipynb
@@ -1,6 +1,7 @@
{
"cells": [
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "w5_pa5kKPzAE"
@@ -10,6 +11,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "1tGC1kVjPNX9"
@@ -19,6 +21,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "lSXa_rQQQzBd"
@@ -28,6 +31,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "OnmoAw2vQG8I"
@@ -43,6 +47,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "l4MP9uUNQ2kr"
@@ -53,6 +58,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "aYzY4OM6F3ay"
@@ -62,6 +68,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "kETDiaP2Rrdb"
@@ -71,6 +78,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "Cg96MkbcRtQR"
@@ -92,10 +100,11 @@
},
"outputs": [],
"source": [
- "pip install camel-ai==0.2.0"
+ "pip install camel-ai==0.2.1"
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "MyTTCe3IR_Lr"
@@ -105,6 +114,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "REqzgGL9SEaD"
@@ -142,6 +152,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "LRojeqp7dP1m"
@@ -151,6 +162,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "_sJV9GFldTBh"
@@ -186,6 +198,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "MBx8Pje9ETAL"
@@ -213,6 +226,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "PCqjf_fWEdLD"
@@ -238,6 +252,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "yR5ZYr5yEkLL"
@@ -247,6 +262,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "Gfc6WNUOEktw"
@@ -282,6 +298,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "412MphuYErw_"
@@ -316,6 +333,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "TIpjz3G2E5dy"
@@ -349,6 +367,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "523x8XqLE8Qo"
@@ -382,6 +401,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "TURczNJNFA3J"
@@ -415,6 +435,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "eRhObgkxFFUi"
@@ -452,6 +473,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "seSeG3KAHbLI"
@@ -461,6 +483,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "kAyagBo0GusE"
@@ -514,6 +537,7 @@
]
},
{
+ "attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "HYNA7G06FJRq"
diff --git a/docs/cookbooks/agents_prompting.ipynb b/docs/cookbooks/agents_prompting.ipynb
index 2eff95c76..d23e6fd8f 100644
--- a/docs/cookbooks/agents_prompting.ipynb
+++ b/docs/cookbooks/agents_prompting.ipynb
@@ -63,7 +63,7 @@
},
"outputs": [],
"source": [
- "!pip install camel-ai==0.2.0"
+ "!pip install camel-ai==0.2.1"
]
},
{
diff --git a/docs/cookbooks/agents_society.ipynb b/docs/cookbooks/agents_society.ipynb
index ba87f7d4c..05fe79717 100644
--- a/docs/cookbooks/agents_society.ipynb
+++ b/docs/cookbooks/agents_society.ipynb
@@ -192,7 +192,7 @@
},
"outputs": [],
"source": [
- "pip install camel-ai==0.2.0"
+ "pip install camel-ai==0.2.1"
]
},
{
diff --git a/docs/cookbooks/agents_tracking.ipynb b/docs/cookbooks/agents_tracking.ipynb
index 869c5d17a..c145ec03d 100644
--- a/docs/cookbooks/agents_tracking.ipynb
+++ b/docs/cookbooks/agents_tracking.ipynb
@@ -77,7 +77,7 @@
},
"outputs": [],
"source": [
- "%pip install camel-ai[all]==0.2.0\n",
+ "%pip install camel-ai[all]==0.2.1\n",
"%pip install agentops==0.3.10"
]
},
diff --git a/docs/cookbooks/agents_with_memory.ipynb b/docs/cookbooks/agents_with_memory.ipynb
index 9c5faf511..cd59139c8 100644
--- a/docs/cookbooks/agents_with_memory.ipynb
+++ b/docs/cookbooks/agents_with_memory.ipynb
@@ -72,7 +72,7 @@
},
"outputs": [],
"source": [
- "pip install camel-ai[all]==0.2.0"
+ "pip install camel-ai[all]==0.2.1"
]
},
{
diff --git a/docs/cookbooks/agents_with_tools.ipynb b/docs/cookbooks/agents_with_tools.ipynb
index 3d7c6e68e..a8826c96b 100644
--- a/docs/cookbooks/agents_with_tools.ipynb
+++ b/docs/cookbooks/agents_with_tools.ipynb
@@ -76,7 +76,7 @@
},
"outputs": [],
"source": [
- "!pip install camel-ai[all]==0.2.0"
+ "!pip install camel-ai[all]==0.2.1"
]
},
{
diff --git a/docs/cookbooks/create_your_first_agent.ipynb b/docs/cookbooks/create_your_first_agent.ipynb
index cfb41003b..c2487cb67 100644
--- a/docs/cookbooks/create_your_first_agent.ipynb
+++ b/docs/cookbooks/create_your_first_agent.ipynb
@@ -76,7 +76,7 @@
{
"cell_type": "code",
"source": [
- "!pip install camel-ai[all]==0.2.0"
+ "!pip install camel-ai[all]==0.2.1"
],
"metadata": {
"id": "UtcC3c-KVZmU"
diff --git a/docs/cookbooks/create_your_first_agents_society.ipynb b/docs/cookbooks/create_your_first_agents_society.ipynb
index cae34d430..b3c3f05ea 100644
--- a/docs/cookbooks/create_your_first_agents_society.ipynb
+++ b/docs/cookbooks/create_your_first_agents_society.ipynb
@@ -74,7 +74,7 @@
{
"cell_type": "code",
"source": [
- "!pip install camel-ai==0.2.0"
+ "!pip install camel-ai==0.2.1"
],
"metadata": {
"id": "RiwfwyyLYYxo"
diff --git a/docs/cookbooks/knowledge_graph.ipynb b/docs/cookbooks/knowledge_graph.ipynb
index bfa36842c..3a54f9718 100644
--- a/docs/cookbooks/knowledge_graph.ipynb
+++ b/docs/cookbooks/knowledge_graph.ipynb
@@ -86,7 +86,7 @@
},
"outputs": [],
"source": [
- "pip install camel-ai[all]==0.2.0"
+ "pip install camel-ai[all]==0.2.1"
]
},
{
diff --git a/docs/cookbooks/task_generation.ipynb b/docs/cookbooks/task_generation.ipynb
index ea1dfbae6..e3bc9db59 100644
--- a/docs/cookbooks/task_generation.ipynb
+++ b/docs/cookbooks/task_generation.ipynb
@@ -61,7 +61,7 @@
},
"outputs": [],
"source": [
- "!pip install camel-ai==0.2.0"
+ "!pip install camel-ai==0.2.1"
]
},
{
diff --git a/docs/get_started/setup.md b/docs/get_started/setup.md
index 38ae89c46..c620e37e3 100644
--- a/docs/get_started/setup.md
+++ b/docs/get_started/setup.md
@@ -61,7 +61,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
-git clone -b v0.2.0 https://github.com/camel-ai/camel.git
+git clone -b v0.2.1 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
diff --git a/examples/loaders/firecrawl_example.py b/examples/loaders/firecrawl_example.py
index 4363cd2f8..99fb85ee8 100644
--- a/examples/loaders/firecrawl_example.py
+++ b/examples/loaders/firecrawl_example.py
@@ -20,19 +20,7 @@ from camel.loaders import Firecrawl
firecrawl = Firecrawl()
-job_id = firecrawl.crawl(
- url="https://www.camel-ai.org/about", wait_until_done=False
-)
-
-print(job_id)
-
-'''
-===============================================================================
-d2123e54-63c9-4feb-98f9-03b7ddeb0f1f
-===============================================================================
-'''
-
-response = firecrawl.check_crawl_job("d2123e54-63c9-4feb-98f9-03b7ddeb0f1f")
+response = firecrawl.crawl(url="https://www.camel-ai.org/about")
print(response["status"])
'''
diff --git a/pyproject.toml b/pyproject.toml
index dc56dd8a4..00824d543 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "camel-ai"
-version = "0.2.0"
+version = "0.2.1"
authors = ["CAMEL-AI.org"]
description = "Communicative Agents for AI Society Study"
readme = "README.md"
diff --git a/test/loaders/test_firecrawl.py b/test/loaders/test_firecrawl.py
index 51f43de09..e8e6313ac 100644
--- a/test/loaders/test_firecrawl.py
+++ b/test/loaders/test_firecrawl.py
@@ -177,35 +177,6 @@ def test_structured_scrape_failure():
assert 'Failed to perform structured scrape' in str(e)
-def test_tidy_scrape_success():
- with patch('firecrawl.FirecrawlApp') as MockFirecrawlApp:
- mock_app = MockFirecrawlApp.return_value
- firecrawl = Firecrawl(
- api_key='test_api_key', api_url='https://api.test.com'
- )
- url = 'https://example.com'
- response = {'markdown': 'Tidy content'}
- mock_app.scrape_url.return_value = response
-
- result = firecrawl.tidy_scrape(url)
- assert result == 'Tidy content'
-
-
-def test_tidy_scrape_failure():
- with patch('firecrawl.FirecrawlApp') as MockFirecrawlApp:
- mock_app = MockFirecrawlApp.return_value
- firecrawl = Firecrawl(
- api_key='test_api_key', api_url='https://api.test.com'
- )
- url = 'https://example.com'
- mock_app.scrape_url.side_effect = Exception('Error')
-
- try:
- firecrawl.tidy_scrape(url)
- except RuntimeError as e:
- assert 'Failed to perform tidy scrape' in str(e)
-
-
def test_map_site_success():
with patch('firecrawl.FirecrawlApp') as MockFirecrawlApp:
mock_app = MockFirecrawlApp.return_value