Skip to content

Commit 4049913

Browse files
committed
alternative to extract tools details for Browser which has a probematic implementation
1 parent dd632fb commit 4049913

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

interpreter/core/computer/browser/browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, computer):
1616
self._driver = None
1717

1818
@property
19-
def driver(self, headless=True):
19+
def driver(self, headless=False):
2020
if self._driver is None:
2121
self.setup(headless)
2222
return self._driver

interpreter/core/computer/computer.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, interpreter):
6565
A python `computer` module is ALREADY IMPORTED, and can be used for many tasks:
6666
6767
```python
68-
{self._get_all_computer_tools_signature_and_description()}
68+
{"\n".join(self._get_all_computer_tools_signature_and_description())}
6969
```
7070
7171
Do not import the computer module, or any of its sub-modules. They are already imported.
@@ -109,6 +109,27 @@ def _extract_tool_info(self, tool):
109109
"signature": tool.__class__.__name__,
110110
"methods": []
111111
}
112+
if tool.__class__.__name__ == "Browser":
113+
methods = []
114+
for name in dir(tool):
115+
if 'driver' in name:
116+
continue # Skip methods containing 'driver' in their name
117+
attr = getattr(tool, name)
118+
if callable(attr) and not name.startswith('_') and not hasattr(attr, '__wrapped__') and not isinstance(attr, property):
119+
# Construct the method signature manually
120+
param_str = ", ".join(
121+
param for param in attr.__code__.co_varnames[:attr.__code__.co_argcount]
122+
)
123+
full_signature = f"computer.{tool.__class__.__name__.lower()}.{name}({param_str})"
124+
# Get the method description
125+
method_description = attr.__doc__ or ""
126+
# Append the method details
127+
tool_info["methods"].append({
128+
"signature": full_signature,
129+
"description": method_description.strip()
130+
})
131+
return tool_info
132+
112133
for name, method in inspect.getmembers(tool, predicate=inspect.ismethod):
113134
# Check if the method should be ignored based on its decorator
114135
if not name.startswith("_") and not hasattr(method, '__wrapped__'):

0 commit comments

Comments
 (0)