camel-ai 0.2.69a3__py3-none-any.whl → 0.2.69a4__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.69a3'
17
+ __version__ = '0.2.69a4'
18
18
 
19
19
  __all__ = [
20
20
  '__version__',
@@ -1904,36 +1904,12 @@ class ChatAgent(BaseAgent):
1904
1904
  ChatAgent: A new instance of :obj:`ChatAgent` with the same
1905
1905
  configuration.
1906
1906
  """
1907
- import copy
1908
-
1909
1907
  # Create a new instance with the same configuration
1910
1908
  # If with_memory is True, set system_message to None
1911
1909
  # If with_memory is False, use the original system message
1912
1910
  # To avoid duplicated system memory.
1913
1911
  system_message = None if with_memory else self._original_system_message
1914
1912
 
1915
- # Create deep copies of tools to avoid shared state
1916
- cloned_tools: List[Union[FunctionTool, Callable]] = []
1917
- for tool in self._internal_tools.values():
1918
- # Create a new FunctionTool instance to avoid sharing state
1919
- cloned_tool = copy.deepcopy(tool)
1920
- cloned_tools.append(cloned_tool)
1921
-
1922
- # Create deep copies of external tool schemas
1923
- cloned_external_tools: List[
1924
- Union[FunctionTool, Callable, Dict[str, Any]]
1925
- ] = []
1926
- for schema in self._external_tool_schemas.values():
1927
- cloned_schema = copy.deepcopy(schema)
1928
- cloned_external_tools.append(cloned_schema)
1929
-
1930
- # Create deep copies of response terminators to avoid shared state
1931
- cloned_terminators: List[ResponseTerminator] = []
1932
- if self.response_terminators:
1933
- for terminator in self.response_terminators:
1934
- cloned_terminator = copy.deepcopy(terminator)
1935
- cloned_terminators.append(cloned_terminator)
1936
-
1937
1913
  new_agent = ChatAgent(
1938
1914
  system_message=system_message,
1939
1915
  model=self.model_backend.models, # Pass the existing model_backend
@@ -1943,9 +1919,11 @@ class ChatAgent(BaseAgent):
1943
1919
  self.memory.get_context_creator(), "token_limit", None
1944
1920
  ),
1945
1921
  output_language=self._output_language,
1946
- tools=cloned_tools,
1947
- external_tools=cloned_external_tools,
1948
- response_terminators=cloned_terminators,
1922
+ tools=[tool.func for tool in self._internal_tools.values()],
1923
+ external_tools=[
1924
+ schema for schema in self._external_tool_schemas.values()
1925
+ ],
1926
+ response_terminators=self.response_terminators,
1949
1927
  scheduling_strategy=self.model_backend.scheduling_strategy.__name__,
1950
1928
  max_iteration=self.max_iteration,
1951
1929
  stop_event=self.stop_event,
@@ -284,6 +284,13 @@ class SingleAgentWorker(Worker):
284
284
  response = await worker_agent.astep(
285
285
  prompt, response_format=TaskResult
286
286
  )
287
+
288
+ # Get token usage from the response
289
+ usage_info = response.info.get("usage") or response.info.get(
290
+ "token_usage"
291
+ )
292
+ total_tokens = usage_info.get("total_tokens", 0)
293
+
287
294
  except Exception as e:
288
295
  print(
289
296
  f"{Fore.RED}Error processing task {task.id}: "
@@ -294,13 +301,6 @@ class SingleAgentWorker(Worker):
294
301
  # Return agent to pool or let it be garbage collected
295
302
  await self._return_worker_agent(worker_agent)
296
303
 
297
- # Get actual token usage from the agent that processed this task
298
- try:
299
- _, total_token_count = worker_agent.memory.get_context()
300
- except Exception:
301
- # Fallback if memory context unavailable
302
- total_token_count = 0
303
-
304
304
  # Populate additional_info with worker attempt details
305
305
  if task.additional_info is None:
306
306
  task.additional_info = {}
@@ -321,7 +321,7 @@ class SingleAgentWorker(Worker):
321
321
  f"to process task {task.content}",
322
322
  "response_content": response.msg.content,
323
323
  "tool_calls": response.info.get("tool_calls"),
324
- "total_token_count": total_token_count,
324
+ "total_tokens": total_tokens,
325
325
  }
326
326
 
327
327
  # Store the worker attempt in additional_info
@@ -330,9 +330,7 @@ class SingleAgentWorker(Worker):
330
330
  task.additional_info["worker_attempts"].append(worker_attempt_details)
331
331
 
332
332
  # Store the actual token usage for this specific task
333
- task.additional_info["token_usage"] = {
334
- "total_tokens": total_token_count
335
- }
333
+ task.additional_info["token_usage"] = {"total_tokens": total_tokens}
336
334
 
337
335
  print(f"======\n{Fore.GREEN}Reply from {self}:{Fore.RESET}")
338
336
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: camel-ai
3
- Version: 0.2.69a3
3
+ Version: 0.2.69a4
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
@@ -1,4 +1,4 @@
1
- camel/__init__.py,sha256=Ryf5ZVEFpFI3TVgtC_wE9pClrhx8VR7g5d2M9lll1tU,901
1
+ camel/__init__.py,sha256=UtJjquAEThQRkMPBBQETBWgOPPDjxWeuDnkWHwHQrJw,901
2
2
  camel/generators.py,sha256=JRqj9_m1PF4qT6UtybzTQ-KBT9MJQt18OAAYvQ_fr2o,13844
3
3
  camel/human.py,sha256=Xg8x1cS5KK4bQ1SDByiHZnzsRpvRP-KZViNvmu38xo4,5475
4
4
  camel/logger.py,sha256=rZVeOVYuQ9RYJ5Tqyv0usqy0g4zaVEq4qSfZ9nd2640,5755
@@ -7,7 +7,7 @@ camel/agents/__init__.py,sha256=64weKqdvmpZcGWyVkO-OKASAmVUdrQjv60JApgPk_SA,1644
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=QFFyJOZ0fsyjjX_KwKsbp-SIFEFC6KTzMZ4dT98JsVg,80333
10
+ camel/agents/chat_agent.py,sha256=x0-PgQ2ptvqHYv_nu2tcWdWn7szl8o6TzYjr739U4Rk,79407
11
11
  camel/agents/critic_agent.py,sha256=L6cTbYjyZB0DCa51tQ6LZLA6my8kHLC4nktHySH78H4,10433
12
12
  camel/agents/deductive_reasoner_agent.py,sha256=6BZGaq1hR6hKJuQtOfoYQnk_AkZpw_Mr7mUy2MspQgs,13540
13
13
  camel/agents/embodied_agent.py,sha256=XBxBu5ZMmSJ4B2U3Z7SMwvLlgp6yNpaBe8HNQmY9CZA,7536
@@ -273,7 +273,7 @@ camel/societies/workforce/__init__.py,sha256=bkTI-PE-MSK9AQ2V2gR6cR2WY-R7Jqy_NmX
273
273
  camel/societies/workforce/base.py,sha256=z2DmbTP5LL5-aCAAqglznQqCLfPmnyM5zD3w6jjtsb8,2175
274
274
  camel/societies/workforce/prompts.py,sha256=_l7OUkzH5p7KOd8HMZle9zB9W3jKza_Yb_6elFKiZ2s,11813
275
275
  camel/societies/workforce/role_playing_worker.py,sha256=pWPCtkLx-xbc4SWyZBfMwvWr-R5ZpANhN7g6PDuH8Po,7615
276
- camel/societies/workforce/single_agent_worker.py,sha256=5lF9zzxDJMCtELh6Y407m_D2bMAXMsY3yvY3_Bssd5A,14704
276
+ camel/societies/workforce/single_agent_worker.py,sha256=ZDVq5doJUoUY0Uuvhkucf4U--y36q1We3p3c4TuoBSM,14627
277
277
  camel/societies/workforce/task_channel.py,sha256=uqQQI67Tr4awbR4bjZXdx8_4gL6-ON5IjQk_H_ryqT4,7431
278
278
  camel/societies/workforce/utils.py,sha256=Gjlz7pLo4r1b6iNHtlIMxeEuat4d6tEEQMI40JAU3kY,6190
279
279
  camel/societies/workforce/worker.py,sha256=36tkOyz4G2wfBdrFjt9NBPXsx4UbE6uL5on8sP2aoqk,6414
@@ -431,7 +431,7 @@ camel/verifiers/math_verifier.py,sha256=tA1D4S0sm8nsWISevxSN0hvSVtIUpqmJhzqfbuMo
431
431
  camel/verifiers/models.py,sha256=GdxYPr7UxNrR1577yW4kyroRcLGfd-H1GXgv8potDWU,2471
432
432
  camel/verifiers/physics_verifier.py,sha256=c1grrRddcrVN7szkxhv2QirwY9viIRSITWeWFF5HmLs,30187
433
433
  camel/verifiers/python_verifier.py,sha256=ogTz77wODfEcDN4tMVtiSkRQyoiZbHPY2fKybn59lHw,20558
434
- camel_ai-0.2.69a3.dist-info/METADATA,sha256=IqaSVunoJDMvh0Hp12M5MItps4OkEnqbmPx4NVi_xZw,45047
435
- camel_ai-0.2.69a3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
436
- camel_ai-0.2.69a3.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
437
- camel_ai-0.2.69a3.dist-info/RECORD,,
434
+ camel_ai-0.2.69a4.dist-info/METADATA,sha256=vhax7Mw7tHuk_bMtaNMfj-CHqCAXzEhvEZP5x6xPPzk,45047
435
+ camel_ai-0.2.69a4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
436
+ camel_ai-0.2.69a4.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
437
+ camel_ai-0.2.69a4.dist-info/RECORD,,