Spaces:
Paused
Paused
Update tools/go_back.py
Browse files- tools/go_back.py +18 -16
tools/go_back.py
CHANGED
|
@@ -1,16 +1,18 @@
|
|
| 1 |
-
from typing import Any
|
| 2 |
-
from smolagents.tools import Tool
|
| 3 |
-
|
| 4 |
-
class GoBackTool(Tool):
|
| 5 |
-
name = "go_back"
|
| 6 |
-
description = "Goes back to the previous page."
|
| 7 |
-
inputs = {}
|
| 8 |
-
output_type = "
|
| 9 |
-
|
| 10 |
-
def
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
def
|
| 16 |
-
self.
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
from smolagents.tools import Tool
|
| 3 |
+
|
| 4 |
+
class GoBackTool(Tool):
|
| 5 |
+
name = "go_back"
|
| 6 |
+
description = "Goes back to the previous page."
|
| 7 |
+
inputs = {}
|
| 8 |
+
output_type = "null"
|
| 9 |
+
|
| 10 |
+
def __init__(self, driver: Any = None, *args, **kwargs):
|
| 11 |
+
super().__init__(*args, **kwargs)
|
| 12 |
+
self.driver = driver
|
| 13 |
+
self.is_initialized = False
|
| 14 |
+
|
| 15 |
+
def forward(self) -> None:
|
| 16 |
+
if not self.driver:
|
| 17 |
+
raise ValueError("WebDriver instance is required.")
|
| 18 |
+
self.driver.back()
|