Skip to content

Commit b6b17b2

Browse files
committed
Update gif_path for BrowserUse
1 parent 05282ba commit b6b17b2

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

patchwork/steps/BrowserUse/BrowserUse.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ def __init__(self, inputs):
5050
api_key=self.inputs["anthropic_api_key"],
5151
)
5252

53-
gifs_base_path = os.path.join(os.path.dirname(__file__), "../../../tmp/gifs")
54-
if not os.path.exists(gifs_base_path):
55-
os.makedirs(gifs_base_path)
56-
5753
# Configure GIF generation for debugging/visualization
58-
self.generate_gif = (
59-
f"{gifs_base_path}/agent_history_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.gif"
60-
if ("generate_gif" in self.inputs and self.inputs["generate_gif"])
61-
or ("debug" in self.inputs and self.inputs["debug"])
54+
self.gif_path = (
55+
self.inputs.get("gif_path", None)
56+
if "gif_path" in self.inputs
57+
else os.path.join(os.getcwd(), f"agent_history_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.gif")
58+
if ("debug" in self.inputs and self.inputs["debug"])
6259
else False
6360
)
6461

@@ -91,7 +88,7 @@ def run(self) -> dict:
9188
controller=controller,
9289
task=mustache_render(self.inputs["task"], self.inputs["task_value"]),
9390
llm=self.llm,
94-
generate_gif=self.generate_gif,
91+
generate_gif=self.gif_path,
9592
validate_output=True,
9693
initial_actions=self.inputs.get("initial_actions", None),
9794
use_vision=self.inputs.get("use_vision", True),
@@ -117,7 +114,7 @@ def run(self) -> dict:
117114
return {
118115
"history": self.history,
119116
"result": self.history.final_result(),
120-
"generated_gif": self.generate_gif,
117+
"generated_gif": self.gif_path,
121118
}
122119

123120
def __format_history_as_json(self):

patchwork/steps/BrowserUse/typed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BrowserUseInputs(__BrowserUseInputsRequired, total=False):
1313
openai_api_key: Annotated[str, StepTypeConfig(or_op=["google_api_key", "anthropic_api_key"])]
1414
anthropic_api_key: Annotated[str, StepTypeConfig(or_op=["google_api_key", "openai_api_key"])]
1515
google_api_key: Annotated[str, StepTypeConfig(or_op=["openai_api_key", "anthropic_api_key"])]
16-
generate_gif: Optional[bool]
16+
gif_path: Optional[str]
1717
headless: Optional[bool]
1818
initial_actions: Optional[List[Dict[str, Dict[str, Any]]]]
1919
downloads_path: Optional[str]

0 commit comments

Comments
 (0)