Skip to content

Commit df2b175

Browse files
author
yh 林
committed
remove useless fields
1 parent e959bab commit df2b175

File tree

2 files changed

+2
-68
lines changed

2 files changed

+2
-68
lines changed

camel/agents/chat_agent.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,9 +2923,6 @@ def _execute_tool(
29232923
tool_call_id = tool_call_request.tool_call_id
29242924
tool = self._internal_tools[func_name]
29252925

2926-
# Record start time for execution tracking
2927-
start_time = time.time()
2928-
29292926
try:
29302927
raw_result = tool(**args)
29312928
if self.mask_tool_output:
@@ -2946,15 +2943,11 @@ def _execute_tool(
29462943
mask_flag = False
29472944
logger.warning(f"{error_msg} with result: {result}")
29482945

2949-
# Calculate execution time
2950-
execution_time_ms = int((time.time() - start_time) * 1000)
2951-
29522946
return self._record_tool_calling(
29532947
func_name,
29542948
args,
29552949
result,
29562950
tool_call_id,
2957-
execution_time_ms,
29582951
mask_output=mask_flag,
29592952
)
29602953

@@ -2967,10 +2960,6 @@ async def _aexecute_tool(
29672960
tool_call_id = tool_call_request.tool_call_id
29682961
tool = self._internal_tools[func_name]
29692962
import asyncio
2970-
import time
2971-
2972-
# Record start time for execution tracking
2973-
start_time = time.time()
29742963

29752964
try:
29762965
# Try different invocation paths in order of preference
@@ -3002,20 +2991,14 @@ async def _aexecute_tool(
30022991
result = f"Tool execution failed: {error_msg}"
30032992
logger.warning(error_msg)
30042993

3005-
# Calculate execution time
3006-
execution_time_ms = int((time.time() - start_time) * 1000)
3007-
3008-
return self._record_tool_calling(
3009-
func_name, args, result, tool_call_id, execution_time_ms
3010-
)
2994+
return self._record_tool_calling(func_name, args, result, tool_call_id)
30112995

30122996
def _record_tool_calling(
30132997
self,
30142998
func_name: str,
30152999
args: Dict[str, Any],
30163000
result: Any,
30173001
tool_call_id: str,
3018-
execution_time_ms: Optional[int] = None,
30193002
mask_output: bool = False,
30203003
):
30213004
r"""Record the tool calling information in the memory, and return the
@@ -3026,7 +3009,6 @@ def _record_tool_calling(
30263009
args (Dict[str, Any]): The arguments passed to the tool.
30273010
result (Any): The result returned by the tool execution.
30283011
tool_call_id (str): A unique identifier for the tool call.
3029-
execution_time_ms (Optional[int]): Execution time in milliseconds.
30303012
mask_output (bool, optional): Whether to return a sanitized
30313013
placeholder instead of the raw tool output.
30323014
(default: :obj:`False`)
@@ -3075,7 +3057,7 @@ def _record_tool_calling(
30753057

30763058
# Calculate tool cost and token usage
30773059
cost_info = self._tool_cost_calculator.estimate_tool_cost(
3078-
func_name, args, result, execution_time_ms
3060+
func_name, args, result
30793061
)
30803062

30813063
# Record information about this tool call with cost tracking

camel/utils/tool_cost_calculator.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ class ToolCostProfile:
5353

5454
category: ToolCategory
5555
base_tokens: int # Base token consumption
56-
input_token_multiplier: float = 1.0 # Multiplier based on input size
57-
output_token_multiplier: float = 1.0 # Multiplier based on output size
58-
cost_per_token_usd: float = (
59-
0.00001 # Cost per token in USD (default: $0.00001)
60-
)
61-
execution_overhead_ms: int = 0 # Additional execution time overhead
6256

6357

6458
class ToolCostInfo(TypedDict):
@@ -92,77 +86,41 @@ def _initialize_default_profiles(self) -> Dict[str, ToolCostProfile]:
9286
"search_google": ToolCostProfile(
9387
category=ToolCategory.SEARCH_API,
9488
base_tokens=50,
95-
# input_token_multiplier=0.1,
96-
# output_token_multiplier=0.2,
97-
# cost_per_token_usd=0.000005,
98-
# execution_overhead_ms=500,
9989
),
10090
"search_bing": ToolCostProfile(
10191
category=ToolCategory.SEARCH_API,
10292
base_tokens=50,
103-
# input_token_multiplier=0.1,
104-
# output_token_multiplier=0.2,
105-
# cost_per_token_usd=0.000005,
106-
# execution_overhead_ms=500,
10793
),
10894
"search_exa": ToolCostProfile(
10995
category=ToolCategory.SEARCH_API,
11096
base_tokens=50,
111-
# input_token_multiplier=0.1,
112-
# output_token_multiplier=0.2,
113-
# cost_per_token_usd=0.000005,
114-
# execution_overhead_ms=500,
11597
),
11698
# Browser tools - high cost
11799
"browser_visit_page": ToolCostProfile(
118100
category=ToolCategory.BROWSER_AUTOMATION,
119101
base_tokens=200,
120-
# input_token_multiplier=0.05,
121-
# output_token_multiplier=0.1,
122-
# cost_per_token_usd=0.00002,
123-
# execution_overhead_ms=2000,
124102
),
125103
"browser_get_som_screenshot": ToolCostProfile(
126104
category=ToolCategory.BROWSER_AUTOMATION,
127105
base_tokens=500,
128-
# input_token_multiplier=0.0,
129-
# output_token_multiplier=0.0,
130-
# cost_per_token_usd=0.00005,
131-
# execution_overhead_ms=3000,
132106
),
133107
"browser_click": ToolCostProfile(
134108
category=ToolCategory.BROWSER_AUTOMATION,
135109
base_tokens=100,
136-
# input_token_multiplier=0.05,
137-
# output_token_multiplier=0.05,
138-
# cost_per_token_usd=0.00002,
139-
# execution_overhead_ms=1000,
140110
),
141111
"browser_type": ToolCostProfile(
142112
category=ToolCategory.BROWSER_AUTOMATION,
143113
base_tokens=100,
144-
# input_token_multiplier=0.1,
145-
# output_token_multiplier=0.05,
146-
# cost_per_token_usd=0.00002,
147-
# execution_overhead_ms=1000,
148114
),
149115
# Terminal tools - medium cost
150116
"shell_exec": ToolCostProfile(
151117
category=ToolCategory.CODE_EXECUTION,
152118
base_tokens=100,
153-
# input_token_multiplier=0.2,
154-
# output_token_multiplier=0.3,
155-
# cost_per_token_usd=0.00001,
156-
# execution_overhead_ms=1000,
157119
),
158120
# Note-taking tools - low cost
159121
"create_note": ToolCostProfile(
160122
category=ToolCategory.SIMPLE_UTILITY,
161123
base_tokens=50,
162-
# input_token_multiplier=0.1,
163-
# output_token_multiplier=0.0,
164-
# cost_per_token_usd=0.000005,
165-
# execution_overhead_ms=100,
166124
),
167125
}
168126

@@ -171,15 +129,13 @@ def estimate_tool_cost(
171129
tool_name: str,
172130
args: Dict[str, Any],
173131
result: Any,
174-
execution_time_ms: Optional[int] = None,
175132
) -> ToolCostInfo:
176133
"""Estimate the token usage and cost for a tool call.
177134
178135
Args:
179136
tool_name: Name of the tool being called.
180137
args: Arguments passed to the tool.
181138
result: Result returned by the tool.
182-
execution_time_ms: Actual execution time in milliseconds.
183139
184140
Returns:
185141
Dictionary containing token usage and cost estimates.
@@ -190,10 +146,6 @@ def estimate_tool_cost(
190146
profile = ToolCostProfile(
191147
category=ToolCategory.SIMPLE_UTILITY,
192148
base_tokens=100,
193-
# input_token_multiplier=0.1,
194-
# output_token_multiplier=0.1,
195-
# cost_per_token_usd=0.00001,
196-
# execution_overhead_ms=500,
197149
)
198150

199151
# Calculate input tokens

0 commit comments

Comments
 (0)