Skip to content

Commit 2c7e905

Browse files
committed
fixed tools
1 parent 9aca26d commit 2c7e905

3 files changed

Lines changed: 33 additions & 4 deletions

File tree

examples/5_a_day_benchmark/tools/banking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ def execute(self, **kwargs) -> ToolResult:
138138

139139

140140
class BankingGetAssetTool(BaseTool):
141-
"""Get asset information by name."""
141+
"""Get number of shares owned for a stock ticker."""
142142

143143
def __init__(self, banking_state: BankingState):
144144
super().__init__(
145145
"banking.get_asset",
146-
"Get asset information by asset name (e.g., 'AAPL' for Apple stock shares)",
146+
"Get the number of shares you own for a stock ticker symbol (e.g., 'AAPL' returns how many Apple shares you own)",
147147
tool_args=["asset_name"],
148148
)
149149
self.state = banking_state

examples/5_a_day_benchmark/tools/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"code": {"type": "string", "description": "Python code to execute", "nullable": True},
3030
"person": {"type": "string", "description": "Person name", "nullable": True},
3131
"relationship": {"type": "string", "description": "Relationship type", "nullable": True},
32-
"asset_name": {"type": "string", "description": "Asset name (e.g., apple_shares)", "nullable": True},
32+
"asset_name": {"type": "string", "description": "Asset ticker symbol (e.g., AAPL, GOOGL)", "nullable": True},
3333
"symbol": {"type": "string", "description": "Stock symbol (e.g., AAPL)", "nullable": True},
3434
"ticker": {"type": "string", "description": "Stock ticker symbol", "nullable": True},
3535
"date": {"type": "string", "description": "Date (YYYY-MM-DD)", "nullable": True},

examples/5_a_day_benchmark/tools/code_execution.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,42 @@ class CodeExecutionState:
2323
def __init__(self, test_cases: list[dict[str, Any]] | None = None):
2424
self.test_cases = test_cases or []
2525

26+
# Build safe builtins with common functions needed for algorithm problems
27+
safe_builtins = {
28+
**limited_builtins,
29+
'len': len,
30+
'max': max,
31+
'min': min,
32+
'sum': sum,
33+
'abs': abs,
34+
'all': all,
35+
'any': any,
36+
'enumerate': enumerate,
37+
'zip': zip,
38+
'sorted': sorted,
39+
'reversed': reversed,
40+
'map': map,
41+
'filter': filter,
42+
'int': int,
43+
'float': float,
44+
'str': str,
45+
'bool': bool,
46+
'dict': dict,
47+
'set': set,
48+
'list': list,
49+
'tuple': tuple,
50+
'range': range,
51+
'print': print,
52+
}
53+
2654
# Safe execution environment with all RestrictedPython guards
2755
self.safe_env = {
2856
**safe_globals,
29-
"__builtins__": limited_builtins,
57+
"__builtins__": safe_builtins,
3058
"_print_": PrintCollector,
3159
"_getattr_": getattr,
3260
"_getitem_": lambda obj, index: obj[index],
61+
"_getiter_": iter,
3362
"_iter_unpack_sequence_": guarded_iter_unpack_sequence,
3463
"__name__": "restricted_module",
3564
"__metaclass__": type,

0 commit comments

Comments
 (0)