camel-ai 0.2.40__py3-none-any.whl → 0.2.41__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.

camel/__init__.py CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  from camel.logger import disable_logging, enable_logging, set_log_level
16
16
 
17
- __version__ = '0.2.40'
17
+ __version__ = '0.2.41'
18
18
 
19
19
  __all__ = [
20
20
  '__version__',
@@ -603,9 +603,6 @@ class ChatAgent(BaseAgent):
603
603
  self._get_full_tool_schemas(),
604
604
  )
605
605
 
606
- if self.single_iteration:
607
- break
608
-
609
606
  if tool_call_requests := response.tool_call_requests:
610
607
  # Process all tool calls
611
608
  for tool_call_request in tool_call_requests:
@@ -625,6 +622,9 @@ class ChatAgent(BaseAgent):
625
622
  if external_tool_call_requests:
626
623
  break
627
624
 
625
+ if self.single_iteration:
626
+ break
627
+
628
628
  # If we're still here, continue the loop
629
629
  continue
630
630
 
@@ -695,9 +695,6 @@ class ChatAgent(BaseAgent):
695
695
  self._get_full_tool_schemas(),
696
696
  )
697
697
 
698
- if self.single_iteration:
699
- break
700
-
701
698
  if tool_call_requests := response.tool_call_requests:
702
699
  # Process all tool calls
703
700
  for tool_call_request in tool_call_requests:
@@ -718,6 +715,9 @@ class ChatAgent(BaseAgent):
718
715
  if external_tool_call_requests:
719
716
  break
720
717
 
718
+ if self.single_iteration:
719
+ break
720
+
721
721
  # If we're still here, continue the loop
722
722
  continue
723
723
 
@@ -201,19 +201,27 @@ class FewShotGenerator(BaseGenerator):
201
201
  raise TypeError(f"Rationale {rationale} is not a string.")
202
202
 
203
203
  try:
204
- verifier_response = await self.verifier.verify(
205
- solution=rationale,
206
- reference_answer=None,
204
+ verifier_response = await asyncio.wait_for(
205
+ self.verifier.verify(
206
+ solution=rationale,
207
+ reference_answer=None,
208
+ ),
209
+ timeout=180,
207
210
  )
208
211
  if not verifier_response or not verifier_response.result:
209
212
  raise ValueError(
210
213
  "Verifier unsuccessful, response: "
211
214
  f"{verifier_response}"
212
215
  )
213
- except (ValueError, AttributeError) as e:
216
+ except (ValueError, AttributeError, asyncio.TimeoutError) as e:
217
+ error_msg = (
218
+ "Verifier timeout"
219
+ if isinstance(e, asyncio.TimeoutError)
220
+ else f"Verifier issue: {e}"
221
+ )
214
222
  logger.warning(
215
- f"Verifier issue: {e}, "
216
- f"retrying... ({retries + 1}/{max_retries})"
223
+ f"{error_msg}, retrying... "
224
+ f"({retries + 1}/{max_retries})"
217
225
  )
218
226
  retries += 1
219
227
  continue
@@ -74,9 +74,52 @@ class ChatHistoryBlock(MemoryBlock):
74
74
  return list()
75
75
 
76
76
  chat_records: List[MemoryRecord] = []
77
- truncate_idx = -window_size if window_size is not None else 0
78
- for record_dict in record_dicts[truncate_idx:]:
79
- chat_records.append(MemoryRecord.from_dict(record_dict))
77
+ if window_size is not None and window_size >= 0:
78
+ # Initial preserved index: Keep first message
79
+ # if it's SYSTEM/DEVELOPER (index 0)
80
+ start_index = (
81
+ 1
82
+ if (
83
+ record_dicts
84
+ and record_dicts[0]['role_at_backend']
85
+ in {OpenAIBackendRole.SYSTEM, OpenAIBackendRole.DEVELOPER}
86
+ )
87
+ else 0
88
+ )
89
+
90
+ """
91
+ Message Processing Logic:
92
+ 1. Preserve first system/developer message (if needed)
93
+ 2. Keep latest window_size messages from the rest
94
+
95
+ Examples:
96
+ - Case 1: First message is SYSTEM, total 5 messages, window_size=2
97
+ Input: [system_msg, user_msg1, user_msg2, user_msg3, user_msg4]
98
+ Result: [system_msg] + [user_msg3, user_msg4]
99
+
100
+ - Case 2: First message is USER, total 5 messages, window_size=3
101
+ Input: [user_msg1, user_msg2, user_msg3, user_msg4, , user_msg5]
102
+ Result: [user_msg3, user_msg4, , user_msg5]
103
+ """
104
+ preserved_messages = record_dicts[
105
+ :start_index
106
+ ] # Preserve system message (if exists)
107
+ sliding_messages = record_dicts[
108
+ start_index:
109
+ ] # Messages to be truncated
110
+
111
+ # Take last window_size messages (if exceeds limit)
112
+ truncated_messages = sliding_messages[-window_size:]
113
+
114
+ # Combine preserved messages with truncated window messages
115
+ final_records = preserved_messages + truncated_messages
116
+ else:
117
+ # Return full records when no window restriction
118
+ final_records = record_dicts
119
+
120
+ chat_records = [
121
+ MemoryRecord.from_dict(record) for record in final_records
122
+ ]
80
123
 
81
124
  # We assume that, in the chat history memory, the closer the record is
82
125
  # to the current message, the more score it will be.
camel/types/enums.py CHANGED
@@ -902,6 +902,7 @@ class VectorDistance(Enum):
902
902
  class OpenAIBackendRole(Enum):
903
903
  ASSISTANT = "assistant"
904
904
  SYSTEM = "system"
905
+ DEVELOPER = "developer"
905
906
  USER = "user"
906
907
  FUNCTION = "function"
907
908
  TOOL = "tool"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: camel-ai
3
- Version: 0.2.40
3
+ Version: 0.2.41
4
4
  Summary: Communicative Agents for AI Society Study
5
5
  Project-URL: Homepage, https://www.camel-ai.org/
6
6
  Project-URL: Repository, https://github.com/camel-ai/camel
@@ -14,6 +14,7 @@ Requires-Dist: colorama<0.5,>=0.4.6
14
14
  Requires-Dist: docstring-parser<0.16,>=0.15
15
15
  Requires-Dist: httpx<1.0.0dev,>=0.28.0
16
16
  Requires-Dist: jsonschema<5,>=4
17
+ Requires-Dist: mcp>=1.3.0
17
18
  Requires-Dist: openai<2,>=1.68.0
18
19
  Requires-Dist: psutil<6,>=5.9.8
19
20
  Requires-Dist: pydantic<2.10,>=1.9
@@ -1,4 +1,4 @@
1
- camel/__init__.py,sha256=97dr3fL9PmmlSnNm6qdqlyzO86xS3Z1dqIMaU4x_Hnk,912
1
+ camel/__init__.py,sha256=Pvojrkcw9OdbaLHL6wyoc5VwLbd_tJsRg58wVSrP2cs,912
2
2
  camel/generators.py,sha256=JRqj9_m1PF4qT6UtybzTQ-KBT9MJQt18OAAYvQ_fr2o,13844
3
3
  camel/human.py,sha256=9X09UmxI2JqQnhrFfnZ3B9EzFmVfdSWQcjLWTIXKXe0,4962
4
4
  camel/logger.py,sha256=rZVeOVYuQ9RYJ5Tqyv0usqy0g4zaVEq4qSfZ9nd2640,5755
@@ -7,7 +7,7 @@ camel/agents/__init__.py,sha256=OEWDfxima22hjSZWgIu6sn9O_QKBr6cpS8b1Jywou0A,1596
7
7
  camel/agents/_types.py,sha256=ryPRmEXnpNtbFT23GoAcwK-zxWWsIOqYu64mxMx_PhI,1430
8
8
  camel/agents/_utils.py,sha256=AR7Qqgbkmn4X2edYUQf1rdksGUyV5hm3iK1z-Dn0Mcg,6266
9
9
  camel/agents/base.py,sha256=c4bJYL3G3Z41SaFdMPMn8ZjLdFiFaVOFO6EQIfuCVR8,1124
10
- camel/agents/chat_agent.py,sha256=PDkePzYPadPogWV1RTQNzt1D2CapJEgWhZn2SiEGiho,51251
10
+ camel/agents/chat_agent.py,sha256=WfHK6ZNVxnI-AaseWVNORAUlinCobHsByGu0ZSYIr2M,51267
11
11
  camel/agents/critic_agent.py,sha256=qFVlHlQo0CVgmPWfWYLT8_oP_KyzCLFsQw_nN_vu5Bs,7487
12
12
  camel/agents/deductive_reasoner_agent.py,sha256=6BZGaq1hR6hKJuQtOfoYQnk_AkZpw_Mr7mUy2MspQgs,13540
13
13
  camel/agents/embodied_agent.py,sha256=XBxBu5ZMmSJ4B2U3Z7SMwvLlgp6yNpaBe8HNQmY9CZA,7536
@@ -91,7 +91,7 @@ camel/datahubs/huggingface.py,sha256=LgRruML4XnwHrm_jMB-aB-Ha-M9ErRrA7YmiL6saGis
91
91
  camel/datahubs/models.py,sha256=tGb9OP_aomIhnwc0VapJjTg9PmyV_QCp5to9sABXF0Y,978
92
92
  camel/datasets/__init__.py,sha256=WlBpnzL8MejnJdofpJQBYv9KCyu1AZgm0-sTqDht6Aw,1051
93
93
  camel/datasets/base_generator.py,sha256=WJEJTT00J3jv1LHjQ5wPBQSfxX0OkT1tc3Uu4FgQwSI,10735
94
- camel/datasets/few_shot_generator.py,sha256=JB9DLok0ZRa2I-FsQbngLZ5M9FY1jIReXvKYoil2B3c,9671
94
+ camel/datasets/few_shot_generator.py,sha256=JPGpqVcpWFk0lWBMoV6jLdz3B2tNbXUee4bPUqhy10o,10013
95
95
  camel/datasets/models.py,sha256=H0ksOfkwiPFjVr9xHMYbVoj8YTTWaLI2GYiWqesmiVs,2228
96
96
  camel/datasets/self_instruct_generator.py,sha256=9FK-S7N7e-PR5rABj59BCNmUZCd8fS72La612FK0AEM,15837
97
97
  camel/datasets/static_dataset.py,sha256=jPFwR0Kk6LmPFGKFm8SGhZvdee9293gGJBoqucCHdE0,14272
@@ -133,7 +133,7 @@ camel/memories/agent_memories.py,sha256=HysjYAB6srRdb3uE_IXmC94YPZBfGcAUdTlbcbzz
133
133
  camel/memories/base.py,sha256=3BGuExfwwkbkVpxw1uYms8O37F-PD8ArcmYnFKYUcI4,5652
134
134
  camel/memories/records.py,sha256=ySZewkQ4uqBtx3MlqX7xyQyKfL_wudxZSAOqIHzf0vA,4319
135
135
  camel/memories/blocks/__init__.py,sha256=ci7_WU11222cNd1Zkv-a0z5E2ux95NMjAYm_cDzF0pE,854
136
- camel/memories/blocks/chat_history_block.py,sha256=RHoIhFHlMD18QGtCGap1MSfjm7JAbIjtpKYsWV-jRX0,5045
136
+ camel/memories/blocks/chat_history_block.py,sha256=klDXMw85ygsU95ibOugOPz2pPx4BWqxN8xUbTJRKBlE,6705
137
137
  camel/memories/blocks/vectordb_block.py,sha256=lf0ipY4cJMB--tQDvpInqsmHZCn7sD1pkmjC70vTtn4,3941
138
138
  camel/memories/context_creators/__init__.py,sha256=pqzkBM2ro5JZD7RhWg05TjinphhCq0QTIqBJlIL1sJ0,800
139
139
  camel/memories/context_creators/score_based.py,sha256=b35GNjioYgFueXIFr-Yk2NlJHLlaOvLj3Yh_b_qRrrA,10313
@@ -346,7 +346,7 @@ camel/toolkits/open_api_specs/web_scraper/openapi.yaml,sha256=u_WalQ01e8W1D27VnZ
346
346
  camel/toolkits/open_api_specs/web_scraper/paths/__init__.py,sha256=OKCZrQCDwaWtXIN_2rA9FSqEvgpQRieRoHh7Ek6N16A,702
347
347
  camel/toolkits/open_api_specs/web_scraper/paths/scraper.py,sha256=aWy1_ppV4NVVEZfnbN3tu9XA9yAPAC9bRStJ5JuXMRU,1117
348
348
  camel/types/__init__.py,sha256=VLWhAt857IFct3XepY5BNOIhyhDhfmODTezr9jhO_TI,2251
349
- camel/types/enums.py,sha256=24UNCszEdYVHGltmSNWGnQa_0mlYrMY1MB9pP0u3-B0,39262
349
+ camel/types/enums.py,sha256=He4xFBijRcf4uvNI4SXlEYD4VhdbSgn1TKnu-3Tlkew,39290
350
350
  camel/types/openai_types.py,sha256=8ZFzLe-zGmKNPfuVZFzxlxAX98lGf18gtrPhOgMmzus,2104
351
351
  camel/types/unified_model_type.py,sha256=gzb6olQrSDb10ku1PZSEakf-SlAaMgRQ756jfzQux20,4540
352
352
  camel/types/agents/__init__.py,sha256=cbvVkogPoZgcwZrgxLH6EtpGXk0kavF79nOic0Dc1vg,786
@@ -368,7 +368,7 @@ camel/verifiers/base.py,sha256=SQGZPP6p08q4Qmpr1vD-eb0UxBwkl1hpZSm19yV2wWo,14866
368
368
  camel/verifiers/math_verifier.py,sha256=tA1D4S0sm8nsWISevxSN0hvSVtIUpqmJhzqfbuMo0y4,6875
369
369
  camel/verifiers/models.py,sha256=GdxYPr7UxNrR1577yW4kyroRcLGfd-H1GXgv8potDWU,2471
370
370
  camel/verifiers/python_verifier.py,sha256=o1VVINq4YQqNPz8h1FiZ7v2dMBN3wlH6AsRWPqN0iGQ,18037
371
- camel_ai-0.2.40.dist-info/METADATA,sha256=aM-HL5lqavR47XPzcbLuE8EIq8gWv5zEqhoSFV3TvbI,42007
372
- camel_ai-0.2.40.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
373
- camel_ai-0.2.40.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
374
- camel_ai-0.2.40.dist-info/RECORD,,
371
+ camel_ai-0.2.41.dist-info/METADATA,sha256=nZHt9rZqnrURzdvTIMWAPIGpKbo60IVfGFu7Za_F8Jo,42033
372
+ camel_ai-0.2.41.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
373
+ camel_ai-0.2.41.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
374
+ camel_ai-0.2.41.dist-info/RECORD,,