camel-ai 0.2.21__py3-none-any.whl → 0.2.23a0__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.

Potentially problematic release.


This version of camel-ai might be problematic. Click here for more details.

Files changed (106) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/_types.py +41 -0
  3. camel/agents/_utils.py +188 -0
  4. camel/agents/chat_agent.py +556 -965
  5. camel/agents/knowledge_graph_agent.py +7 -1
  6. camel/agents/multi_hop_generator_agent.py +1 -1
  7. camel/configs/base_config.py +10 -13
  8. camel/configs/deepseek_config.py +4 -30
  9. camel/configs/gemini_config.py +5 -31
  10. camel/configs/openai_config.py +14 -32
  11. camel/configs/qwen_config.py +36 -36
  12. camel/datagen/self_improving_cot.py +79 -1
  13. camel/datagen/self_instruct/filter/instruction_filter.py +19 -3
  14. camel/datagen/self_instruct/self_instruct.py +7 -2
  15. camel/datasets/__init__.py +28 -0
  16. camel/datasets/base.py +969 -0
  17. camel/embeddings/openai_embedding.py +10 -1
  18. camel/environments/__init__.py +16 -0
  19. camel/environments/base.py +503 -0
  20. camel/extractors/__init__.py +16 -0
  21. camel/extractors/base.py +263 -0
  22. camel/interpreters/docker/Dockerfile +12 -0
  23. camel/interpreters/docker_interpreter.py +19 -1
  24. camel/interpreters/subprocess_interpreter.py +42 -17
  25. camel/loaders/__init__.py +2 -0
  26. camel/loaders/mineru_extractor.py +250 -0
  27. camel/memories/agent_memories.py +16 -1
  28. camel/memories/blocks/chat_history_block.py +10 -2
  29. camel/memories/blocks/vectordb_block.py +1 -0
  30. camel/memories/context_creators/score_based.py +20 -3
  31. camel/memories/records.py +10 -0
  32. camel/messages/base.py +8 -8
  33. camel/models/_utils.py +57 -0
  34. camel/models/aiml_model.py +48 -17
  35. camel/models/anthropic_model.py +41 -3
  36. camel/models/azure_openai_model.py +39 -3
  37. camel/models/base_model.py +132 -4
  38. camel/models/cohere_model.py +88 -11
  39. camel/models/deepseek_model.py +107 -63
  40. camel/models/gemini_model.py +133 -15
  41. camel/models/groq_model.py +72 -10
  42. camel/models/internlm_model.py +14 -3
  43. camel/models/litellm_model.py +9 -2
  44. camel/models/mistral_model.py +42 -5
  45. camel/models/model_manager.py +48 -3
  46. camel/models/moonshot_model.py +33 -4
  47. camel/models/nemotron_model.py +32 -3
  48. camel/models/nvidia_model.py +43 -3
  49. camel/models/ollama_model.py +139 -17
  50. camel/models/openai_audio_models.py +7 -1
  51. camel/models/openai_compatible_model.py +37 -3
  52. camel/models/openai_model.py +158 -46
  53. camel/models/qwen_model.py +61 -4
  54. camel/models/reka_model.py +53 -3
  55. camel/models/samba_model.py +209 -4
  56. camel/models/sglang_model.py +153 -14
  57. camel/models/siliconflow_model.py +16 -3
  58. camel/models/stub_model.py +46 -4
  59. camel/models/togetherai_model.py +38 -3
  60. camel/models/vllm_model.py +37 -3
  61. camel/models/yi_model.py +36 -3
  62. camel/models/zhipuai_model.py +38 -3
  63. camel/retrievers/__init__.py +3 -0
  64. camel/retrievers/hybrid_retrival.py +237 -0
  65. camel/toolkits/__init__.py +9 -2
  66. camel/toolkits/arxiv_toolkit.py +2 -1
  67. camel/toolkits/ask_news_toolkit.py +4 -2
  68. camel/toolkits/base.py +22 -3
  69. camel/toolkits/code_execution.py +2 -0
  70. camel/toolkits/dappier_toolkit.py +2 -1
  71. camel/toolkits/data_commons_toolkit.py +38 -12
  72. camel/toolkits/function_tool.py +13 -0
  73. camel/toolkits/github_toolkit.py +5 -1
  74. camel/toolkits/google_maps_toolkit.py +2 -1
  75. camel/toolkits/google_scholar_toolkit.py +2 -0
  76. camel/toolkits/human_toolkit.py +0 -3
  77. camel/toolkits/linkedin_toolkit.py +3 -2
  78. camel/toolkits/meshy_toolkit.py +3 -2
  79. camel/toolkits/mineru_toolkit.py +178 -0
  80. camel/toolkits/networkx_toolkit.py +240 -0
  81. camel/toolkits/notion_toolkit.py +2 -0
  82. camel/toolkits/openbb_toolkit.py +3 -2
  83. camel/toolkits/reddit_toolkit.py +11 -3
  84. camel/toolkits/retrieval_toolkit.py +6 -1
  85. camel/toolkits/semantic_scholar_toolkit.py +2 -1
  86. camel/toolkits/stripe_toolkit.py +8 -2
  87. camel/toolkits/sympy_toolkit.py +44 -1
  88. camel/toolkits/video_toolkit.py +2 -0
  89. camel/toolkits/whatsapp_toolkit.py +3 -2
  90. camel/toolkits/zapier_toolkit.py +191 -0
  91. camel/types/__init__.py +2 -2
  92. camel/types/agents/__init__.py +16 -0
  93. camel/types/agents/tool_calling_record.py +52 -0
  94. camel/types/enums.py +3 -0
  95. camel/types/openai_types.py +16 -14
  96. camel/utils/__init__.py +2 -1
  97. camel/utils/async_func.py +2 -2
  98. camel/utils/commons.py +114 -1
  99. camel/verifiers/__init__.py +23 -0
  100. camel/verifiers/base.py +340 -0
  101. camel/verifiers/models.py +82 -0
  102. camel/verifiers/python_verifier.py +202 -0
  103. {camel_ai-0.2.21.dist-info → camel_ai-0.2.23a0.dist-info}/METADATA +273 -256
  104. {camel_ai-0.2.21.dist-info → camel_ai-0.2.23a0.dist-info}/RECORD +106 -85
  105. {camel_ai-0.2.21.dist-info → camel_ai-0.2.23a0.dist-info}/WHEEL +1 -1
  106. {camel_ai-0.2.21.dist-info → camel_ai-0.2.23a0.dist-info}/LICENSE +0 -0
@@ -37,15 +37,16 @@ class OpenBBToolkit(BaseToolkit):
37
37
  (None, "OPENBB_TOKEN"),
38
38
  ]
39
39
  )
40
- def __init__(self) -> None:
40
+ def __init__(self, timeout: Optional[float] = None) -> None:
41
41
  r"""Initialize the OpenBBToolkit.
42
42
 
43
43
  This method sets up the OpenBB client and initializes the OpenBB
44
44
  Hub account system.
45
45
  """
46
+ super().__init__(timeout=timeout)
46
47
  import os
47
48
 
48
- from openbb import obb
49
+ from openbb import obb # type: ignore[import-not-found]
49
50
 
50
51
  self.client = obb
51
52
  # Initialize OpenBB Hub account with access token
@@ -14,7 +14,7 @@
14
14
 
15
15
  import os
16
16
  import time
17
- from typing import Any, Dict, List, Union
17
+ from typing import Any, Dict, List, Optional, Union
18
18
 
19
19
  from camel.toolkits import FunctionTool
20
20
  from camel.toolkits.base import BaseToolkit
@@ -30,11 +30,16 @@ class RedditToolkit(BaseToolkit):
30
30
 
31
31
  Attributes:
32
32
  retries (int): Number of retries for API requests in case of failure.
33
- delay (int): Delay between retries in seconds.
33
+ delay (float): Delay between retries in seconds.
34
34
  reddit (Reddit): An instance of the Reddit client.
35
35
  """
36
36
 
37
- def __init__(self, retries: int = 3, delay: int = 0):
37
+ def __init__(
38
+ self,
39
+ retries: int = 3,
40
+ delay: float = 0.0,
41
+ timeout: Optional[float] = None,
42
+ ):
38
43
  r"""Initializes the RedditToolkit with the specified number of retries
39
44
  and delay.
40
45
 
@@ -43,7 +48,10 @@ class RedditToolkit(BaseToolkit):
43
48
  failure. Defaults to `3`.
44
49
  delay (int): Time in seconds to wait between retries. Defaults to
45
50
  `0`.
51
+ timeout (float): Timeout for API requests in seconds. Defaults to
52
+ `None`.
46
53
  """
54
+ super().__init__(timeout=timeout)
47
55
  from praw import Reddit # type: ignore[import-untyped]
48
56
 
49
57
  self.retries = retries
@@ -27,8 +27,13 @@ class RetrievalToolkit(BaseToolkit):
27
27
  storage system based on a specified query.
28
28
  """
29
29
 
30
- def __init__(self, auto_retriever: Optional[AutoRetriever] = None) -> None:
30
+ def __init__(
31
+ self,
32
+ auto_retriever: Optional[AutoRetriever] = None,
33
+ timeout: Optional[float] = None,
34
+ ) -> None:
31
35
  r"""Initializes a new instance of the RetrievalToolkit class."""
36
+ super().__init__(timeout=timeout)
32
37
  self.ar = auto_retriever or AutoRetriever(
33
38
  vector_storage_local_path="camel/temp_storage",
34
39
  storage_type=StorageType.QDRANT,
@@ -26,8 +26,9 @@ class SemanticScholarToolkit(BaseToolkit):
26
26
  API to fetch paper and author data.
27
27
  """
28
28
 
29
- def __init__(self):
29
+ def __init__(self, timeout: Optional[float] = None):
30
30
  r"""Initializes the SemanticScholarToolkit."""
31
+ super().__init__(timeout=timeout)
31
32
  self.base_url = "https://api.semanticscholar.org/graph/v1"
32
33
 
33
34
  def fetch_paper_data_title(
@@ -15,7 +15,7 @@
15
15
  import json
16
16
  import logging
17
17
  import os
18
- from typing import List
18
+ from typing import List, Optional
19
19
 
20
20
  from camel.toolkits import FunctionTool
21
21
  from camel.toolkits.base import BaseToolkit
@@ -41,7 +41,12 @@ class StripeToolkit(BaseToolkit):
41
41
  (None, "STRIPE_API_KEY"),
42
42
  ]
43
43
  )
44
- def __init__(self, retries: int = 3):
44
+ def __init__(
45
+ self,
46
+ retries: int = 3,
47
+ timeout: Optional[float] = None,
48
+ ):
49
+ super().__init__(timeout=timeout)
45
50
  r"""Initializes the StripeToolkit with the specified number of
46
51
  retries.
47
52
 
@@ -49,6 +54,7 @@ class StripeToolkit(BaseToolkit):
49
54
  retries (int,optional): Number of times to retry the request in
50
55
  case of failure. (default: :obj:`3`)
51
56
  """
57
+ super().__init__(timeout=timeout)
52
58
  import stripe
53
59
 
54
60
  stripe.max_network_retries = retries
@@ -28,13 +28,18 @@ class SymPyToolkit(BaseToolkit):
28
28
  and Linear Algebra.
29
29
  """
30
30
 
31
- def __init__(self, default_variable: str = 'x'):
31
+ def __init__(
32
+ self,
33
+ default_variable: str = 'x',
34
+ timeout: Optional[float] = None,
35
+ ):
32
36
  r"""Initializes the toolkit with a default variable and logging.
33
37
 
34
38
  Args:
35
39
  default_variable (str): The default variable for
36
40
  operations (default: :obj: `x`)
37
41
  """
42
+ super().__init__(timeout=timeout)
38
43
  self.default_variable = default_variable
39
44
  logger.info(f"Default variable set to: {self.default_variable}")
40
45
 
@@ -721,6 +726,43 @@ class SymPyToolkit(BaseToolkit):
721
726
  except Exception as e:
722
727
  return self.handle_exception("compute_rank", e)
723
728
 
729
+ def compute_inner_product(
730
+ self, vector1: List[float], vector2: List[float]
731
+ ) -> str:
732
+ r"""Computes the inner (dot) product of two vectors.
733
+
734
+ Args:
735
+ vector1 (List[float]): The first vector as a list of floats.
736
+ vector2 (List[float]): The second vector as a list of floats.
737
+
738
+ Returns:
739
+ str: JSON string containing the inner product in the `"result"`
740
+ field. If an error occurs, the JSON string will include an
741
+ `"error"` field with the corresponding error message.
742
+
743
+ Raises:
744
+ ValueError: If the vectors have different dimensions.
745
+ """
746
+ import sympy as sp
747
+
748
+ try:
749
+ # Convert the lists into sympy Matrix objects (column vectors)
750
+ v1 = sp.Matrix(vector1)
751
+ v2 = sp.Matrix(vector2)
752
+
753
+ # Check that the vectors have the same dimensions.
754
+ if v1.shape != v2.shape:
755
+ raise ValueError(
756
+ "Vectors must have the same dimensions to compute "
757
+ "the inner product."
758
+ )
759
+
760
+ # Compute the dot (inner) product.
761
+ inner_product = v1.dot(v2)
762
+ return json.dumps({"result": str(inner_product)})
763
+ except Exception as e:
764
+ return self.handle_exception("compute_inner_product", e)
765
+
724
766
  def handle_exception(self, func_name: str, error: Exception) -> str:
725
767
  r"""Handles exceptions by logging and returning error details.
726
768
 
@@ -775,4 +817,5 @@ class SymPyToolkit(BaseToolkit):
775
817
  FunctionTool(self.compute_eigenvectors),
776
818
  FunctionTool(self.compute_nullspace),
777
819
  FunctionTool(self.compute_rank),
820
+ FunctionTool(self.compute_inner_product),
778
821
  ]
@@ -85,7 +85,9 @@ class VideoDownloaderToolkit(BaseToolkit):
85
85
  self,
86
86
  download_directory: Optional[str] = None,
87
87
  cookies_path: Optional[str] = None,
88
+ timeout: Optional[float] = None,
88
89
  ) -> None:
90
+ super().__init__(timeout=timeout)
89
91
  self._cleanup = download_directory is None
90
92
  self._cookies_path = cookies_path
91
93
 
@@ -13,7 +13,7 @@
13
13
  # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
 
15
15
  import os
16
- from typing import Any, Dict, List, Union
16
+ from typing import Any, Dict, List, Optional, Union
17
17
 
18
18
  import requests
19
19
 
@@ -36,8 +36,9 @@ class WhatsAppToolkit(BaseToolkit):
36
36
  version (str): API version.
37
37
  """
38
38
 
39
- def __init__(self):
39
+ def __init__(self, timeout: Optional[float] = None):
40
40
  r"""Initializes the WhatsAppToolkit."""
41
+ super().__init__(timeout=timeout)
41
42
  self.base_url = "https://graph.facebook.com"
42
43
  self.version = "v17.0"
43
44
 
@@ -0,0 +1,191 @@
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
+
15
+ import os
16
+ from typing import Any, Dict, List
17
+
18
+ import requests
19
+
20
+ from camel.toolkits.base import BaseToolkit
21
+ from camel.toolkits.function_tool import FunctionTool
22
+ from camel.utils import api_keys_required, dependencies_required
23
+
24
+
25
+ class ZapierToolkit(BaseToolkit):
26
+ r"""A class representing a toolkit for interacting with Zapier's NLA API.
27
+
28
+ This class provides methods for executing Zapier actions through natural
29
+ language commands, allowing integration with various web services and
30
+ automation of workflows through the Zapier platform.
31
+
32
+ Attributes:
33
+ api_key (str): The API key for authenticating with Zapier's API.
34
+ base_url (str): The base URL for Zapier's API endpoints.
35
+ """
36
+
37
+ @dependencies_required("requests")
38
+ @api_keys_required(
39
+ [
40
+ (None, "ZAPIER_NLA_API_KEY"),
41
+ ]
42
+ )
43
+ def __init__(self) -> None:
44
+ r"""Initialize the ZapierToolkit with API client. The API key is
45
+ retrieved from environment variables.
46
+ """
47
+ self.api_key = os.environ.get("ZAPIER_NLA_API_KEY")
48
+ self.base_url = "https://actions.zapier.com/api/v1/"
49
+
50
+ def list_actions(self) -> Dict[str, Any]:
51
+ r"""List all available Zapier actions.
52
+
53
+ Returns:
54
+ Dict[str, Any]: A dictionary containing the list of available
55
+ actions.
56
+ """
57
+ headers = {
58
+ 'accept': 'application/json',
59
+ 'x-api-key': self.api_key,
60
+ }
61
+ response = requests.get(
62
+ f"{self.base_url}exposed/",
63
+ params={'api_key': self.api_key},
64
+ headers=headers,
65
+ )
66
+ response.raise_for_status()
67
+ return response.json()
68
+
69
+ def execute_action(
70
+ self,
71
+ action_id: str,
72
+ instructions: str,
73
+ ) -> Dict[str, Any]:
74
+ r"""Execute a specific Zapier action using natural language
75
+ instructions.
76
+
77
+ Args:
78
+ action_id (str): The ID of the Zapier action to execute.
79
+ instructions (str): Natural language instructions for executing
80
+ the action. For example: "Send an email to john@example.com
81
+ with subject 'Hello' and body 'How are you?'"
82
+
83
+ Returns:
84
+ Dict[str, Any]: The result of the action execution, including
85
+ status and any output data.
86
+ """
87
+ try:
88
+ headers = {
89
+ 'accept': 'application/json',
90
+ 'x-api-key': self.api_key,
91
+ 'Content-Type': 'application/json',
92
+ }
93
+ data = {
94
+ "instructions": instructions,
95
+ "preview_only": False,
96
+ }
97
+ response = requests.post(
98
+ f"{self.base_url}exposed/{action_id}/execute/",
99
+ params={'api_key': self.api_key},
100
+ headers=headers,
101
+ json=data,
102
+ )
103
+ response.raise_for_status()
104
+ return response.json()
105
+ except requests.exceptions.RequestException as e:
106
+ return {"error": f"Request failed: {e!s}"}
107
+ except ValueError:
108
+ return {"error": "Response is not valid JSON"}
109
+
110
+ def preview_action(
111
+ self,
112
+ action_id: str,
113
+ instructions: str,
114
+ ) -> Dict[str, Any]:
115
+ r"""Preview a specific Zapier action using natural language
116
+ instructions.
117
+
118
+ Args:
119
+ action_id (str): The ID of the Zapier action to preview.
120
+ instructions (str): Natural language instructions for previewing
121
+ the action. For example: "Send an email to john@example.com
122
+ with subject 'Hello' and body 'How are you?'"
123
+
124
+ Returns:
125
+ Dict[str, Any]: The preview result showing what parameters would
126
+ be used if the action were executed.
127
+ """
128
+ try:
129
+ headers = {
130
+ 'accept': 'application/json',
131
+ 'x-api-key': self.api_key,
132
+ 'Content-Type': 'application/json',
133
+ }
134
+ data = {
135
+ "instructions": instructions,
136
+ "preview_only": True,
137
+ }
138
+ response = requests.post(
139
+ f"{self.base_url}exposed/{action_id}/execute/",
140
+ params={'api_key': self.api_key},
141
+ headers=headers,
142
+ json=data,
143
+ )
144
+ response.raise_for_status()
145
+ return response.json()
146
+ except requests.exceptions.RequestException as e:
147
+ return {"error": f"Request failed: {e!s}"}
148
+ except ValueError:
149
+ return {"error": "Response is not valid JSON"}
150
+
151
+ def get_execution_result(self, execution_id: str) -> Dict[str, Any]:
152
+ r"""Get the execution result of a Zapier action.
153
+
154
+ Args:
155
+ execution_id (str): The execution ID returned from execute_action.
156
+
157
+ Returns:
158
+ Dict[str, Any]: The execution result containing status, logs,
159
+ and any output data from the action execution.
160
+ """
161
+ try:
162
+ headers = {
163
+ 'accept': 'application/json',
164
+ 'x-api-key': self.api_key,
165
+ }
166
+ response = requests.get(
167
+ f"{self.base_url}execution-log/{execution_id}/",
168
+ params={'api_key': self.api_key},
169
+ headers=headers,
170
+ )
171
+ response.raise_for_status()
172
+ return response.json()
173
+ except requests.exceptions.RequestException as e:
174
+ return {"error": f"Request failed: {e!s}"}
175
+ except ValueError:
176
+ return {"error": "Response is not valid JSON"}
177
+
178
+ def get_tools(self) -> List[FunctionTool]:
179
+ r"""Returns a list of FunctionTool objects representing the functions
180
+ in the toolkit.
181
+
182
+ Returns:
183
+ List[FunctionTool]: A list of FunctionTool objects representing
184
+ the functions in the toolkit.
185
+ """
186
+ return [
187
+ FunctionTool(self.list_actions),
188
+ FunctionTool(self.execute_action),
189
+ FunctionTool(self.preview_action),
190
+ FunctionTool(self.get_execution_result),
191
+ ]
camel/types/__init__.py CHANGED
@@ -73,8 +73,8 @@ __all__ = [
73
73
  'AudioModelType',
74
74
  'VoiceType',
75
75
  'UnifiedModelType',
76
- 'NOT_GIVEN',
77
- 'NotGiven',
78
76
  'ParsedChatCompletion',
79
77
  'HuggingFaceRepoType',
78
+ 'NOT_GIVEN',
79
+ 'NotGiven',
80
80
  ]
@@ -0,0 +1,16 @@
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
+ from .tool_calling_record import ToolCallingRecord
15
+
16
+ __all__ = ["ToolCallingRecord"]
@@ -0,0 +1,52 @@
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
+ from typing import Any, Dict
15
+
16
+ from pydantic import BaseModel
17
+
18
+
19
+ class ToolCallingRecord(BaseModel):
20
+ r"""Historical records of tools called in the conversation.
21
+
22
+ Attributes:
23
+ func_name (str): The name of the tool being called.
24
+ args (Dict[str, Any]): The dictionary of arguments passed to the tool.
25
+ result (Any): The execution result of calling this tool.
26
+ tool_call_id (str): The ID of the tool call, if available.
27
+ """
28
+
29
+ tool_name: str
30
+ args: Dict[str, Any]
31
+ result: Any
32
+ tool_call_id: str
33
+
34
+ def __str__(self) -> str:
35
+ r"""Overridden version of the string function.
36
+
37
+ Returns:
38
+ str: Modified string to represent the tool calling.
39
+ """
40
+ return (
41
+ f"Tool Execution: {self.tool_name}\n"
42
+ f"\tArgs: {self.args}\n"
43
+ f"\tResult: {self.result}\n"
44
+ )
45
+
46
+ def as_dict(self) -> dict[str, Any]:
47
+ r"""Returns the tool calling record as a dictionary.
48
+
49
+ Returns:
50
+ dict[str, Any]: The tool calling record as a dictionary.
51
+ """
52
+ return self.model_dump()
camel/types/enums.py CHANGED
@@ -34,6 +34,7 @@ class ModelType(UnifiedModelType, Enum):
34
34
  GPT_4_TURBO = "gpt-4-turbo"
35
35
  GPT_4O = "gpt-4o"
36
36
  GPT_4O_MINI = "gpt-4o-mini"
37
+ GPT_4_5_PREVIEW = "gpt-4.5-preview"
37
38
  O1 = "o1"
38
39
  O1_PREVIEW = "o1-preview"
39
40
  O1_MINI = "o1-mini"
@@ -263,6 +264,7 @@ class ModelType(UnifiedModelType, Enum):
263
264
  ModelType.O1_PREVIEW,
264
265
  ModelType.O1_MINI,
265
266
  ModelType.O3_MINI,
267
+ ModelType.GPT_4_5_PREVIEW,
266
268
  }
267
269
 
268
270
  @property
@@ -623,6 +625,7 @@ class ModelType(UnifiedModelType, Enum):
623
625
  ModelType.GPT_4_TURBO,
624
626
  ModelType.O1_PREVIEW,
625
627
  ModelType.O1_MINI,
628
+ ModelType.GPT_4_5_PREVIEW,
626
629
  ModelType.MISTRAL_LARGE,
627
630
  ModelType.MISTRAL_NEMO,
628
631
  ModelType.MISTRAL_PIXTRAL_12B,
@@ -35,17 +35,19 @@ from openai.types.chat import ParsedChatCompletion
35
35
  from openai._types import NOT_GIVEN, NotGiven
36
36
  from openai.types.chat import ChatCompletionMessageToolCall
37
37
 
38
- Choice = Choice
39
- ChatCompletion = ChatCompletion
40
- ChatCompletionChunk = ChatCompletionChunk
41
- ChatCompletionMessage = ChatCompletionMessage
42
- ChatCompletionMessageParam = ChatCompletionMessageParam
43
- ChatCompletionSystemMessageParam = ChatCompletionSystemMessageParam
44
- ChatCompletionUserMessageParam = ChatCompletionUserMessageParam
45
- ChatCompletionAssistantMessageParam = ChatCompletionAssistantMessageParam
46
- ChatCompletionToolMessageParam = ChatCompletionToolMessageParam
47
- ChatCompletionMessageToolCall = ChatCompletionMessageToolCall
48
- CompletionUsage = CompletionUsage
49
- NOT_GIVEN = NOT_GIVEN
50
- NotGiven = NotGiven
51
- ParsedChatCompletion = ParsedChatCompletion
38
+ __all__ = [
39
+ "Choice",
40
+ "ChatCompletion",
41
+ "ChatCompletionChunk",
42
+ "ChatCompletionMessage",
43
+ "ChatCompletionMessageParam",
44
+ "ChatCompletionSystemMessageParam",
45
+ "ChatCompletionUserMessageParam",
46
+ "ChatCompletionAssistantMessageParam",
47
+ "ChatCompletionToolMessageParam",
48
+ "ChatCompletionMessageToolCall",
49
+ "CompletionUsage",
50
+ "ParsedChatCompletion",
51
+ "NOT_GIVEN",
52
+ "NotGiven",
53
+ ]
camel/utils/__init__.py CHANGED
@@ -23,7 +23,6 @@ from .commons import (
23
23
  download_github_subdirectory,
24
24
  download_tasks,
25
25
  func_string_to_callable,
26
- generate_prompt_for_structured_output,
27
26
  get_first_int,
28
27
  get_prompt_template_key_words,
29
28
  get_pydantic_major_version,
@@ -38,6 +37,7 @@ from .commons import (
38
37
  text_extract_from_web,
39
38
  to_pascal,
40
39
  track_agent,
40
+ with_timeout,
41
41
  )
42
42
  from .constants import Constants
43
43
  from .deduplication import DeduplicationResult, deduplicate_internally
@@ -87,4 +87,5 @@ __all__ = [
87
87
  "DeduplicationResult",
88
88
  "retry_on_error",
89
89
  "BatchProcessor",
90
+ "with_timeout",
90
91
  ]
camel/utils/async_func.py CHANGED
@@ -33,8 +33,8 @@ def sync_funcs_to_async(funcs: list[FunctionTool]) -> list[FunctionTool]:
33
33
  for func in funcs:
34
34
  sync_func = func.func
35
35
 
36
- def async_callable(*args, **kwargs):
37
- return asyncio.to_thread(sync_func, *args, **kwargs) # noqa: B023
36
+ async def async_callable(*args, **kwargs):
37
+ return await asyncio.to_thread(sync_func, *args, **kwargs) # noqa: B023
38
38
 
39
39
  async_funcs.append(
40
40
  FunctionTool(async_callable, deepcopy(func.openai_tool_schema))