camel-ai 0.2.73a4__py3-none-any.whl → 0.2.80a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- camel/__init__.py +1 -1
- camel/agents/_utils.py +38 -0
- camel/agents/chat_agent.py +2217 -519
- camel/agents/mcp_agent.py +30 -27
- camel/configs/__init__.py +15 -0
- camel/configs/aihubmix_config.py +88 -0
- camel/configs/amd_config.py +70 -0
- camel/configs/cometapi_config.py +104 -0
- camel/configs/minimax_config.py +93 -0
- camel/configs/nebius_config.py +103 -0
- camel/data_collectors/alpaca_collector.py +15 -6
- camel/datasets/base_generator.py +39 -10
- camel/environments/single_step.py +28 -3
- camel/environments/tic_tac_toe.py +1 -1
- camel/interpreters/__init__.py +2 -0
- camel/interpreters/docker/Dockerfile +3 -12
- camel/interpreters/e2b_interpreter.py +34 -1
- camel/interpreters/microsandbox_interpreter.py +395 -0
- camel/loaders/__init__.py +11 -2
- camel/loaders/chunkr_reader.py +9 -0
- camel/memories/agent_memories.py +48 -4
- camel/memories/base.py +26 -0
- camel/memories/blocks/chat_history_block.py +122 -4
- camel/memories/context_creators/score_based.py +25 -384
- camel/memories/records.py +88 -8
- camel/messages/base.py +153 -34
- camel/models/__init__.py +10 -0
- camel/models/aihubmix_model.py +83 -0
- camel/models/aiml_model.py +1 -16
- camel/models/amd_model.py +101 -0
- camel/models/anthropic_model.py +6 -19
- camel/models/aws_bedrock_model.py +2 -33
- camel/models/azure_openai_model.py +114 -89
- camel/models/base_audio_model.py +3 -1
- camel/models/base_model.py +32 -14
- camel/models/cohere_model.py +1 -16
- camel/models/cometapi_model.py +83 -0
- camel/models/crynux_model.py +1 -16
- camel/models/deepseek_model.py +1 -16
- camel/models/fish_audio_model.py +6 -0
- camel/models/gemini_model.py +36 -18
- camel/models/groq_model.py +1 -17
- camel/models/internlm_model.py +1 -16
- camel/models/litellm_model.py +1 -16
- camel/models/lmstudio_model.py +1 -17
- camel/models/minimax_model.py +83 -0
- camel/models/mistral_model.py +1 -16
- camel/models/model_factory.py +27 -1
- camel/models/modelscope_model.py +1 -16
- camel/models/moonshot_model.py +105 -24
- camel/models/nebius_model.py +83 -0
- camel/models/nemotron_model.py +0 -5
- camel/models/netmind_model.py +1 -16
- camel/models/novita_model.py +1 -16
- camel/models/nvidia_model.py +1 -16
- camel/models/ollama_model.py +4 -19
- camel/models/openai_compatible_model.py +62 -41
- camel/models/openai_model.py +62 -57
- camel/models/openrouter_model.py +1 -17
- camel/models/ppio_model.py +1 -16
- camel/models/qianfan_model.py +1 -16
- camel/models/qwen_model.py +1 -16
- camel/models/reka_model.py +1 -16
- camel/models/samba_model.py +34 -47
- camel/models/sglang_model.py +64 -31
- camel/models/siliconflow_model.py +1 -16
- camel/models/stub_model.py +0 -4
- camel/models/togetherai_model.py +1 -16
- camel/models/vllm_model.py +1 -16
- camel/models/volcano_model.py +0 -17
- camel/models/watsonx_model.py +1 -16
- camel/models/yi_model.py +1 -16
- camel/models/zhipuai_model.py +60 -16
- camel/parsers/__init__.py +18 -0
- camel/parsers/mcp_tool_call_parser.py +176 -0
- camel/retrievers/auto_retriever.py +1 -0
- camel/runtimes/daytona_runtime.py +11 -12
- camel/societies/__init__.py +2 -0
- camel/societies/workforce/__init__.py +2 -0
- camel/societies/workforce/events.py +122 -0
- camel/societies/workforce/prompts.py +146 -66
- camel/societies/workforce/role_playing_worker.py +15 -11
- camel/societies/workforce/single_agent_worker.py +302 -65
- camel/societies/workforce/structured_output_handler.py +30 -18
- camel/societies/workforce/task_channel.py +163 -27
- camel/societies/workforce/utils.py +107 -13
- camel/societies/workforce/workflow_memory_manager.py +772 -0
- camel/societies/workforce/workforce.py +1949 -579
- camel/societies/workforce/workforce_callback.py +74 -0
- camel/societies/workforce/workforce_logger.py +168 -145
- camel/societies/workforce/workforce_metrics.py +33 -0
- camel/storages/key_value_storages/json.py +15 -2
- camel/storages/key_value_storages/mem0_cloud.py +48 -47
- camel/storages/object_storages/google_cloud.py +1 -1
- camel/storages/vectordb_storages/oceanbase.py +13 -13
- camel/storages/vectordb_storages/qdrant.py +3 -3
- camel/storages/vectordb_storages/tidb.py +8 -6
- camel/tasks/task.py +4 -3
- camel/toolkits/__init__.py +20 -7
- camel/toolkits/aci_toolkit.py +45 -0
- camel/toolkits/base.py +6 -4
- camel/toolkits/code_execution.py +28 -1
- camel/toolkits/context_summarizer_toolkit.py +684 -0
- camel/toolkits/dappier_toolkit.py +5 -1
- camel/toolkits/dingtalk.py +1135 -0
- camel/toolkits/edgeone_pages_mcp_toolkit.py +11 -31
- camel/toolkits/excel_toolkit.py +1 -1
- camel/toolkits/{file_write_toolkit.py → file_toolkit.py} +430 -36
- camel/toolkits/function_tool.py +13 -3
- camel/toolkits/github_toolkit.py +104 -17
- camel/toolkits/gmail_toolkit.py +1839 -0
- camel/toolkits/google_calendar_toolkit.py +38 -4
- camel/toolkits/google_drive_mcp_toolkit.py +12 -31
- camel/toolkits/hybrid_browser_toolkit/config_loader.py +15 -0
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py +77 -8
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit_ts.py +884 -88
- camel/toolkits/hybrid_browser_toolkit/installer.py +203 -0
- camel/toolkits/hybrid_browser_toolkit/ts/package-lock.json +5 -612
- camel/toolkits/hybrid_browser_toolkit/ts/package.json +0 -1
- camel/toolkits/hybrid_browser_toolkit/ts/src/browser-session.ts +959 -89
- camel/toolkits/hybrid_browser_toolkit/ts/src/config-loader.ts +9 -2
- camel/toolkits/hybrid_browser_toolkit/ts/src/hybrid-browser-toolkit.ts +281 -213
- camel/toolkits/hybrid_browser_toolkit/ts/src/parent-child-filter.ts +226 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/snapshot-parser.ts +219 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/som-screenshot-injected.ts +543 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/types.ts +23 -3
- camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js +72 -7
- camel/toolkits/hybrid_browser_toolkit/ws_wrapper.py +582 -132
- camel/toolkits/hybrid_browser_toolkit_py/actions.py +158 -0
- camel/toolkits/hybrid_browser_toolkit_py/browser_session.py +55 -8
- camel/toolkits/hybrid_browser_toolkit_py/config_loader.py +43 -0
- camel/toolkits/hybrid_browser_toolkit_py/hybrid_browser_toolkit.py +321 -8
- camel/toolkits/hybrid_browser_toolkit_py/snapshot.py +10 -4
- camel/toolkits/hybrid_browser_toolkit_py/unified_analyzer.js +45 -4
- camel/toolkits/{openai_image_toolkit.py → image_generation_toolkit.py} +151 -53
- camel/toolkits/klavis_toolkit.py +5 -1
- camel/toolkits/markitdown_toolkit.py +27 -1
- camel/toolkits/math_toolkit.py +64 -10
- camel/toolkits/mcp_toolkit.py +366 -71
- camel/toolkits/memory_toolkit.py +5 -1
- camel/toolkits/message_integration.py +18 -13
- camel/toolkits/minimax_mcp_toolkit.py +195 -0
- camel/toolkits/note_taking_toolkit.py +19 -10
- camel/toolkits/notion_mcp_toolkit.py +16 -26
- camel/toolkits/openbb_toolkit.py +5 -1
- camel/toolkits/origene_mcp_toolkit.py +8 -49
- camel/toolkits/playwright_mcp_toolkit.py +12 -31
- camel/toolkits/resend_toolkit.py +168 -0
- camel/toolkits/search_toolkit.py +264 -91
- camel/toolkits/slack_toolkit.py +64 -10
- camel/toolkits/terminal_toolkit/__init__.py +18 -0
- camel/toolkits/terminal_toolkit/terminal_toolkit.py +957 -0
- camel/toolkits/terminal_toolkit/utils.py +532 -0
- camel/toolkits/vertex_ai_veo_toolkit.py +590 -0
- camel/toolkits/video_analysis_toolkit.py +17 -11
- camel/toolkits/wechat_official_toolkit.py +483 -0
- camel/toolkits/zapier_toolkit.py +5 -1
- camel/types/__init__.py +2 -2
- camel/types/enums.py +274 -7
- camel/types/openai_types.py +2 -2
- camel/types/unified_model_type.py +15 -0
- camel/utils/commons.py +36 -5
- camel/utils/constants.py +3 -0
- camel/utils/context_utils.py +1003 -0
- camel/utils/mcp.py +138 -4
- camel/utils/token_counting.py +43 -20
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/METADATA +223 -83
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/RECORD +170 -141
- camel/loaders/pandas_reader.py +0 -368
- camel/toolkits/openai_agent_toolkit.py +0 -135
- camel/toolkits/terminal_toolkit.py +0 -1550
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/licenses/LICENSE +0 -0
|
@@ -45,8 +45,21 @@ class GoogleCalendarToolkit(BaseToolkit):
|
|
|
45
45
|
timeout (Optional[float]): The timeout value for API requests
|
|
46
46
|
in seconds. If None, no timeout is applied.
|
|
47
47
|
(default: :obj:`None`)
|
|
48
|
+
|
|
49
|
+
Note:
|
|
50
|
+
Before using this toolkit, make sure to:
|
|
51
|
+
1. Set the required environment variables: GOOGLE_CLIENT_ID and
|
|
52
|
+
GOOGLE_CLIENT_SECRET
|
|
53
|
+
2. Configure the redirect URI in Google Cloud Console to
|
|
54
|
+
http://localhost/
|
|
48
55
|
"""
|
|
49
56
|
super().__init__(timeout=timeout)
|
|
57
|
+
logger.info(
|
|
58
|
+
"Initializing GoogleCalendarToolkit. Make sure to set "
|
|
59
|
+
"GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables, "
|
|
60
|
+
"and configure the redirect URI in Google Cloud Console to "
|
|
61
|
+
"http://localhost/"
|
|
62
|
+
)
|
|
50
63
|
self.service = self._get_calendar_service()
|
|
51
64
|
|
|
52
65
|
def create_event(
|
|
@@ -197,15 +210,36 @@ class GoogleCalendarToolkit(BaseToolkit):
|
|
|
197
210
|
|
|
198
211
|
result = []
|
|
199
212
|
for event in events:
|
|
200
|
-
|
|
201
|
-
|
|
213
|
+
start_info = event.get('start', {})
|
|
214
|
+
end_info = event.get('end', {})
|
|
215
|
+
start_time = start_info.get(
|
|
216
|
+
'dateTime', start_info.get('date', 'Unknown')
|
|
217
|
+
)
|
|
218
|
+
end_time = end_info.get(
|
|
219
|
+
'dateTime', end_info.get('date', 'Unknown')
|
|
220
|
+
)
|
|
221
|
+
timezone = (
|
|
222
|
+
start_info.get('timeZone')
|
|
223
|
+
or end_info.get('timeZone')
|
|
224
|
+
or event.get('timeZone')
|
|
202
225
|
)
|
|
226
|
+
attendees = [
|
|
227
|
+
attendee.get('email')
|
|
228
|
+
for attendee in event.get('attendees', [])
|
|
229
|
+
if attendee.get('email')
|
|
230
|
+
]
|
|
231
|
+
organizer = event.get('organizer', {}).get('email')
|
|
232
|
+
|
|
203
233
|
result.append(
|
|
204
234
|
{
|
|
205
|
-
'Event ID': event
|
|
235
|
+
'Event ID': event.get('id'),
|
|
206
236
|
'Summary': event.get('summary', 'No Title'),
|
|
207
|
-
'Start Time':
|
|
237
|
+
'Start Time': start_time,
|
|
238
|
+
'End Time': end_time,
|
|
239
|
+
'Timezone': timezone,
|
|
208
240
|
'Link': event.get('htmlLink'),
|
|
241
|
+
'Attendees': attendees,
|
|
242
|
+
'Organizer': organizer,
|
|
209
243
|
}
|
|
210
244
|
)
|
|
211
245
|
|
|
@@ -12,14 +12,12 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
|
|
15
|
-
from typing import
|
|
16
|
-
|
|
17
|
-
from camel.toolkits import BaseToolkit, FunctionTool
|
|
15
|
+
from typing import Optional
|
|
18
16
|
|
|
19
17
|
from .mcp_toolkit import MCPToolkit
|
|
20
18
|
|
|
21
19
|
|
|
22
|
-
class GoogleDriveMCPToolkit(
|
|
20
|
+
class GoogleDriveMCPToolkit(MCPToolkit):
|
|
23
21
|
r"""GoogleDriveMCPToolkit provides an interface for interacting with
|
|
24
22
|
Google Drive using the Google Drive MCP server.
|
|
25
23
|
|
|
@@ -41,33 +39,16 @@ class GoogleDriveMCPToolkit(BaseToolkit):
|
|
|
41
39
|
credentials_path (Optional[str]): Path to the Google Drive
|
|
42
40
|
credentials file. (default: :obj:`None`)
|
|
43
41
|
"""
|
|
44
|
-
super().__init__(timeout=timeout)
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"env": {"GDRIVE_CREDENTIALS_PATH": credentials_path},
|
|
53
|
-
}
|
|
43
|
+
config_dict = {
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"gdrive": {
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["-y", "@modelcontextprotocol/server-gdrive"],
|
|
48
|
+
"env": {"GDRIVE_CREDENTIALS_PATH": credentials_path},
|
|
54
49
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
async def connect(self):
|
|
60
|
-
r"""Explicitly connect to the Google Drive MCP server."""
|
|
61
|
-
await self._mcp_toolkit.connect()
|
|
62
|
-
|
|
63
|
-
async def disconnect(self):
|
|
64
|
-
r"""Explicitly disconnect from the Google Drive MCP server."""
|
|
65
|
-
await self._mcp_toolkit.disconnect()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
List[FunctionTool]: List of available tools.
|
|
72
|
-
"""
|
|
73
|
-
return self._mcp_toolkit.get_tools()
|
|
53
|
+
# Initialize parent MCPToolkit with Playwright configuration
|
|
54
|
+
super().__init__(config_dict=config_dict, timeout=timeout)
|
|
@@ -23,6 +23,7 @@ class BrowserConfig:
|
|
|
23
23
|
headless: bool = True
|
|
24
24
|
user_data_dir: Optional[str] = None
|
|
25
25
|
stealth: bool = False
|
|
26
|
+
console_log_limit: int = 1000
|
|
26
27
|
|
|
27
28
|
# Default settings
|
|
28
29
|
default_start_url: str = "https://google.com/"
|
|
@@ -42,6 +43,10 @@ class BrowserConfig:
|
|
|
42
43
|
# CDP connection configuration
|
|
43
44
|
connect_over_cdp: bool = False
|
|
44
45
|
cdp_url: Optional[str] = None
|
|
46
|
+
cdp_keep_current_page: bool = False
|
|
47
|
+
|
|
48
|
+
# Full visual mode configuration
|
|
49
|
+
full_visual_mode: bool = False
|
|
45
50
|
|
|
46
51
|
|
|
47
52
|
@dataclass
|
|
@@ -50,6 +55,7 @@ class ToolkitConfig:
|
|
|
50
55
|
|
|
51
56
|
cache_dir: str = "tmp/"
|
|
52
57
|
browser_log_to_file: bool = False
|
|
58
|
+
log_dir: Optional[str] = None
|
|
53
59
|
session_id: Optional[str] = None
|
|
54
60
|
enabled_tools: Optional[list] = None
|
|
55
61
|
|
|
@@ -105,6 +111,10 @@ class ConfigLoader:
|
|
|
105
111
|
browser_kwargs["connect_over_cdp"] = value
|
|
106
112
|
elif key == "cdpUrl":
|
|
107
113
|
browser_kwargs["cdp_url"] = value
|
|
114
|
+
elif key == "cdpKeepCurrentPage":
|
|
115
|
+
browser_kwargs["cdp_keep_current_page"] = value
|
|
116
|
+
elif key == "consoleLogLimit":
|
|
117
|
+
browser_kwargs["console_log_limit"] = value
|
|
108
118
|
elif key == "cacheDir":
|
|
109
119
|
toolkit_kwargs["cache_dir"] = value
|
|
110
120
|
elif key == "browserLogToFile":
|
|
@@ -113,6 +123,8 @@ class ConfigLoader:
|
|
|
113
123
|
toolkit_kwargs["session_id"] = value
|
|
114
124
|
elif key == "enabledTools":
|
|
115
125
|
toolkit_kwargs["enabled_tools"] = value
|
|
126
|
+
elif key == "fullVisualMode":
|
|
127
|
+
browser_kwargs["full_visual_mode"] = value
|
|
116
128
|
|
|
117
129
|
browser_config = BrowserConfig(**browser_kwargs)
|
|
118
130
|
toolkit_config = ToolkitConfig(**toolkit_kwargs)
|
|
@@ -139,10 +151,13 @@ class ConfigLoader:
|
|
|
139
151
|
"screenshotTimeout": self.browser_config.screenshot_timeout,
|
|
140
152
|
"pageStabilityTimeout": self.browser_config.page_stability_timeout,
|
|
141
153
|
"browser_log_to_file": self.toolkit_config.browser_log_to_file,
|
|
154
|
+
"log_dir": self.toolkit_config.log_dir,
|
|
142
155
|
"session_id": self.toolkit_config.session_id,
|
|
143
156
|
"viewport_limit": self.browser_config.viewport_limit,
|
|
144
157
|
"connectOverCdp": self.browser_config.connect_over_cdp,
|
|
145
158
|
"cdpUrl": self.browser_config.cdp_url,
|
|
159
|
+
"cdpKeepCurrentPage": self.browser_config.cdp_keep_current_page,
|
|
160
|
+
"fullVisualMode": self.browser_config.full_visual_mode,
|
|
146
161
|
}
|
|
147
162
|
|
|
148
163
|
def get_timeout_config(self) -> Dict[str, Optional[int]]:
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
from typing import Any, List, Literal, Optional
|
|
16
16
|
|
|
17
|
-
from camel.models import BaseModelBackend
|
|
18
17
|
from camel.toolkits.base import BaseToolkit
|
|
19
18
|
|
|
20
19
|
|
|
@@ -25,6 +24,64 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
25
24
|
This wrapper allows users to choose between:
|
|
26
25
|
- 'typescript': WebSocket-based implementation using TypeScript/Node.js
|
|
27
26
|
- 'python': Pure Python implementation using Playwright directly
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
mode (Literal["typescript", "python"]): Implementation mode. -
|
|
30
|
+
'typescript': Uses WebSocket-based TypeScript implementation -
|
|
31
|
+
'python': Uses pure Python Playwright implementation. Defaults to
|
|
32
|
+
"typescript".
|
|
33
|
+
headless (bool): Whether to run browser in headless mode.
|
|
34
|
+
Defaults to True.
|
|
35
|
+
user_data_dir (Optional[str]): Directory for user data
|
|
36
|
+
persistence. Defaults to None.
|
|
37
|
+
stealth (bool): Whether to enable stealth mode. Defaults to
|
|
38
|
+
False.
|
|
39
|
+
cache_dir (str): Directory for caching. Defaults to "tmp/".
|
|
40
|
+
enabled_tools (Optional[List[str]]): List of enabled tools.
|
|
41
|
+
Defaults to None.
|
|
42
|
+
browser_log_to_file (bool): Whether to log browser actions to
|
|
43
|
+
file. Defaults to False.
|
|
44
|
+
log_dir (Optional[str]): Custom directory path for log files.
|
|
45
|
+
If None, defaults to "browser_log". Defaults to None.
|
|
46
|
+
session_id (Optional[str]): Session identifier. Defaults to None.
|
|
47
|
+
default_start_url (str): Default URL to start with. Defaults
|
|
48
|
+
to "https://google.com/".
|
|
49
|
+
default_timeout (Optional[int]): Default timeout in
|
|
50
|
+
milliseconds. Defaults to None.
|
|
51
|
+
short_timeout (Optional[int]): Short timeout in milliseconds.
|
|
52
|
+
Defaults to None.
|
|
53
|
+
navigation_timeout (Optional[int]): Navigation timeout in
|
|
54
|
+
milliseconds. Defaults to None.
|
|
55
|
+
network_idle_timeout (Optional[int]): Network idle timeout in
|
|
56
|
+
milliseconds. Defaults to None.
|
|
57
|
+
screenshot_timeout (Optional[int]): Screenshot timeout in
|
|
58
|
+
milliseconds. Defaults to None.
|
|
59
|
+
page_stability_timeout (Optional[int]): Page stability timeout
|
|
60
|
+
in milliseconds. Defaults to None.
|
|
61
|
+
dom_content_loaded_timeout (Optional[int]): DOM content loaded
|
|
62
|
+
timeout in milliseconds. Defaults to None.
|
|
63
|
+
viewport_limit (bool): Whether to filter page snapshot
|
|
64
|
+
elements to only those visible in the current viewport.
|
|
65
|
+
Defaults to False.
|
|
66
|
+
connect_over_cdp (bool): Whether to connect to an existing
|
|
67
|
+
browser via Chrome DevTools Protocol. Defaults to False.
|
|
68
|
+
(Only supported in TypeScript mode)
|
|
69
|
+
cdp_url (Optional[str]): WebSocket endpoint URL for CDP
|
|
70
|
+
connection. Required when connect_over_cdp is True.
|
|
71
|
+
Defaults to None. (Only supported in TypeScript mode)
|
|
72
|
+
cdp_keep_current_page (bool): When True and using CDP mode,
|
|
73
|
+
won't create new pages but use the existing one. Defaults to False.
|
|
74
|
+
(Only supported in TypeScript mode)
|
|
75
|
+
full_visual_mode (bool): When True, browser actions like click,
|
|
76
|
+
browser_open, visit_page, etc. will return 'full visual mode'
|
|
77
|
+
as snapshot instead of actual page content. The
|
|
78
|
+
browser_get_page_snapshot method will still return the actual
|
|
79
|
+
snapshot. Defaults to False.
|
|
80
|
+
**kwargs: Additional keyword arguments passed to the
|
|
81
|
+
implementation.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
HybridBrowserToolkit instance of the specified implementation.
|
|
28
85
|
"""
|
|
29
86
|
|
|
30
87
|
def __new__(
|
|
@@ -34,12 +91,12 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
34
91
|
headless: bool = True,
|
|
35
92
|
user_data_dir: Optional[str] = None,
|
|
36
93
|
stealth: bool = False,
|
|
37
|
-
|
|
38
|
-
cache_dir: str = "tmp/",
|
|
94
|
+
cache_dir: Optional[str] = None,
|
|
39
95
|
enabled_tools: Optional[List[str]] = None,
|
|
40
96
|
browser_log_to_file: bool = False,
|
|
97
|
+
log_dir: Optional[str] = None,
|
|
41
98
|
session_id: Optional[str] = None,
|
|
42
|
-
default_start_url: str =
|
|
99
|
+
default_start_url: Optional[str] = None,
|
|
43
100
|
default_timeout: Optional[int] = None,
|
|
44
101
|
short_timeout: Optional[int] = None,
|
|
45
102
|
navigation_timeout: Optional[int] = None,
|
|
@@ -50,6 +107,8 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
50
107
|
viewport_limit: bool = False,
|
|
51
108
|
connect_over_cdp: bool = False,
|
|
52
109
|
cdp_url: Optional[str] = None,
|
|
110
|
+
cdp_keep_current_page: bool = False,
|
|
111
|
+
full_visual_mode: bool = False,
|
|
53
112
|
**kwargs: Any,
|
|
54
113
|
) -> Any:
|
|
55
114
|
r"""Create a HybridBrowserToolkit instance with the specified mode.
|
|
@@ -65,13 +124,13 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
65
124
|
persistence. Defaults to None.
|
|
66
125
|
stealth (bool): Whether to enable stealth mode. Defaults to
|
|
67
126
|
False.
|
|
68
|
-
web_agent_model (Optional[BaseModelBackend]): Model for web
|
|
69
|
-
agent operations. Defaults to None.
|
|
70
127
|
cache_dir (str): Directory for caching. Defaults to "tmp/".
|
|
71
128
|
enabled_tools (Optional[List[str]]): List of enabled tools.
|
|
72
129
|
Defaults to None.
|
|
73
130
|
browser_log_to_file (bool): Whether to log browser actions to
|
|
74
131
|
file. Defaults to False.
|
|
132
|
+
log_dir (Optional[str]): Custom directory path for log files.
|
|
133
|
+
If None, defaults to "browser_log". Defaults to None.
|
|
75
134
|
session_id (Optional[str]): Session identifier. Defaults to None.
|
|
76
135
|
default_start_url (str): Default URL to start with. Defaults
|
|
77
136
|
to "https://google.com/".
|
|
@@ -98,6 +157,14 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
98
157
|
cdp_url (Optional[str]): WebSocket endpoint URL for CDP
|
|
99
158
|
connection. Required when connect_over_cdp is True.
|
|
100
159
|
Defaults to None. (Only supported in TypeScript mode)
|
|
160
|
+
cdp_keep_current_page (bool): When True and using CDP mode,
|
|
161
|
+
won't create new pages but use the existing one. Defaults to False.
|
|
162
|
+
(Only supported in TypeScript mode)
|
|
163
|
+
full_visual_mode (bool): When True, browser actions like click,
|
|
164
|
+
browser_open, visit_page, etc. will return 'full visual mode'
|
|
165
|
+
as snapshot instead of actual page content. The
|
|
166
|
+
browser_get_page_snapshot method will still return the actual
|
|
167
|
+
snapshot. Defaults to False.
|
|
101
168
|
**kwargs: Additional keyword arguments passed to the
|
|
102
169
|
implementation.
|
|
103
170
|
|
|
@@ -113,10 +180,10 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
113
180
|
headless=headless,
|
|
114
181
|
user_data_dir=user_data_dir,
|
|
115
182
|
stealth=stealth,
|
|
116
|
-
web_agent_model=web_agent_model,
|
|
117
183
|
cache_dir=cache_dir,
|
|
118
184
|
enabled_tools=enabled_tools,
|
|
119
185
|
browser_log_to_file=browser_log_to_file,
|
|
186
|
+
log_dir=log_dir,
|
|
120
187
|
session_id=session_id,
|
|
121
188
|
default_start_url=default_start_url,
|
|
122
189
|
default_timeout=default_timeout,
|
|
@@ -129,6 +196,8 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
129
196
|
viewport_limit=viewport_limit,
|
|
130
197
|
connect_over_cdp=connect_over_cdp,
|
|
131
198
|
cdp_url=cdp_url,
|
|
199
|
+
cdp_keep_current_page=cdp_keep_current_page,
|
|
200
|
+
full_visual_mode=full_visual_mode,
|
|
132
201
|
**kwargs,
|
|
133
202
|
)
|
|
134
203
|
elif mode == "python":
|
|
@@ -156,10 +225,10 @@ class HybridBrowserToolkit(BaseToolkit):
|
|
|
156
225
|
headless=headless,
|
|
157
226
|
user_data_dir=user_data_dir,
|
|
158
227
|
stealth=stealth,
|
|
159
|
-
web_agent_model=web_agent_model,
|
|
160
228
|
cache_dir=cache_dir,
|
|
161
229
|
enabled_tools=enabled_tools,
|
|
162
230
|
browser_log_to_file=browser_log_to_file,
|
|
231
|
+
log_dir=log_dir,
|
|
163
232
|
session_id=session_id,
|
|
164
233
|
default_start_url=default_start_url,
|
|
165
234
|
default_timeout=default_timeout,
|