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: som screenshot bugs (#2849)

Puzhen Zhang7ca699aa299e
diff --git a/camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py b/camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py
index 176e83e04..f9a49f219 100644
--- a/camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py
+++ b/camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py
@@ -1461,6 +1461,7 @@ class HybridBrowserToolkit(BaseToolkit):
from camel.utils.tool_result import ToolResult
+ os.makedirs(self._cache_dir, exist_ok=True)
# Get screenshot and analysis
page = await self._require_page()
@@ -1539,14 +1540,12 @@ class HybridBrowserToolkit(BaseToolkit):
analysis = await self._get_unified_analysis()
elements = analysis.get("elements", {})
if ref not in elements:
- available_refs = list(elements.keys())
logger.error(f"Error: Element reference '{ref}' not found. ")
# Added snapshot to give more context on failure
snapshot = self._format_snapshot_from_analysis(analysis)
tab_info = await self._get_tab_info_for_output()
return {
- "result": f"Error: Element reference '{ref}' not found. "
- f"Available refs: {available_refs}",
+ "result": f"Error: Element reference '{ref}' not found. ",
"snapshot": snapshot,
**tab_info,
}
diff --git a/camel/toolkits/hybrid_browser_toolkit/unified_analyzer.js b/camel/toolkits/hybrid_browser_toolkit/unified_analyzer.js
index 7c79e1043..85ab2510f 100644
--- a/camel/toolkits/hybrid_browser_toolkit/unified_analyzer.js
+++ b/camel/toolkits/hybrid_browser_toolkit/unified_analyzer.js
@@ -735,11 +735,11 @@
function renderTree(node, indent = '') {
const lines = [];
let meaningfulProps = '';
- if (node.disabled) meaningfulProps += ' disabled';
- if (node.occluded) meaningfulProps += ' occluded';
+ if (node.disabled) meaningfulProps += ' [disabled]';
+ if (node.occluded) meaningfulProps += ' [occluded]';
if (node.checked !== undefined) meaningfulProps += ` checked=${node.checked}`;
if (node.expanded !== undefined) meaningfulProps += ` expanded=${node.expanded}`;
- if (node.selected) meaningfulProps += ' selected';
+ if (node.selected) meaningfulProps += ' [selected]';
// Add level attribute following Playwright's format
if (node.level !== undefined) meaningfulProps += ` [level=${node.level}]`;
diff --git a/camel/toolkits/search_toolkit.py b/camel/toolkits/search_toolkit.py
index 6fe624421..f7ff30e07 100644
--- a/camel/toolkits/search_toolkit.py
+++ b/camel/toolkits/search_toolkit.py
@@ -267,7 +267,7 @@ class SearchToolkit(BaseToolkit):
Country Codes. (default: :obj:`US `)
search_lang (str): The search language preference.
Use ONLY these exact values, NOT standard ISO codes:
- 'ar', 'eu', 'bn', 'bg', 'ca', 'zh-hans', 'zh-hant', 'hr',
+ 'ar', 'eu', 'bn', 'bg', 'ca', 'zh-hans', 'zh-hant', 'hr',
'cs', 'da', 'nl', 'en', 'en-gb', 'et', 'fi', 'fr', 'gl', 'de',
'gu', 'he', 'hi', 'hu', 'is', 'it', 'jp', 'kn', 'ko', 'lv',
'lt', 'ms', 'ml', 'mr', 'nb', 'pl', 'pt-br', 'pt-pt', 'pa',
diff --git a/examples/toolkits/hybrid_browser_toolkit_example.py b/examples/toolkits/hybrid_browser_toolkit_example.py
index eb5df7d62..48208c836 100644
--- a/examples/toolkits/hybrid_browser_toolkit_example.py
+++ b/examples/toolkits/hybrid_browser_toolkit_example.py
@@ -81,7 +81,7 @@ output_dir = "./file_write_outputs"
os.makedirs(output_dir, exist_ok=True)
# Initialize the FileWriteToolkit with the output directory
-file_toolkit = FileWriteToolkit(output_dir=output_dir)
+file_toolkit = FileWriteToolkit(working_directory=output_dir)
# Get the tools from the toolkit
tools_list = file_toolkit.get_tools()
diff --git a/examples/workforce/eigent.py b/examples/workforce/eigent.py
index 40b354510..ec81b184f 100644
--- a/examples/workforce/eigent.py
+++ b/examples/workforce/eigent.py
@@ -212,7 +212,8 @@ def search_agent_factory(
- **Analysis**: Use `get_som_screenshot` to understand the page layout
and identify interactive elements. Since this is a heavy operation,
only use it when visual analysis is necessary.
- - **Interaction**: Use `type` to fill out forms and `enter` to submit.
+ - **Interaction**: Use `type` to fill out forms and `enter`
+ to submit or confirm search.
3. **Detailed Content Extraction**: Prioritize using the scraping tools
from `Crawl4AIToolkit` for in-depth information gathering from a
webpage.
@@ -666,13 +667,9 @@ async def main():
human_task = Task(
content=(
"""
-Analyze the UK healthcare industry to support the planning of my next company.
-Provide a comprehensive market overview, including current trends, growth
-projections, and relevant regulations. Identify the top 5-10 major competitors
-in the space, including their names, website URLs, estimated market size or
-share, core services or products, key strengths, and notable weaknesses. Also
-highlight any significant opportunities, gaps, or underserved segments within
-the market. Present all findings in a well-structured, professional PDF report.
+ go to amazon and find a popular product,
+ check the comments and reviews,
+ and then write a report about the product.
"""
),
id='0',