Skip to content

Commit

Permalink
finished agent
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongnguyen26 committed Feb 1, 2025
1 parent 03dc444 commit 958190d
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 571 deletions.
37 changes: 5 additions & 32 deletions agential/agents/computer_use/webvoyager_baseline/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,10 @@ class WebVoyagerBaseline(BaseAgent):

def __init__( ###### Clean Up Attributes ############

Check warning on line 47 in agential/agents/computer_use/webvoyager_baseline/agent.py

View check run for this annotation

Codecov / codecov/patch

agential/agents/computer_use/webvoyager_baseline/agent.py#L47

Added line #L47 was not covered by tests
self,
output_dir: str,
download_dir: str,
test_file: str = "data/test.json",
max_iter: int = 5,
seed: int = None,
max_attached_imgs: int = 1,
temperature: float = 1.0,
text_only: bool = False,
headless: bool = False,
save_accessibility_tree: bool = False,
force_device_scale: bool = False,
window_width: int = 1024,
window_height: int = 768,
fix_box_color: bool = False,
llm: BaseLLM = LLM(model="gpt-4o"),
testing: bool = False,
benchmark: str = "osworld",
Expand All @@ -82,20 +72,10 @@ def __init__( ###### Clean Up Attributes ############
**strategy_kwargs (Any): Additional arguments for the strategy.
"""
super().__init__(llm=llm, benchmark=benchmark, testing=testing)
self.output_dir = output_dir
self.download_dir = download_dir
self.test_file = test_file
self.max_iter = max_iter
self.seed = seed
self.max_attached_imgs = max_attached_imgs
self.temperature = temperature
self.text_only = text_only
self.headless = headless
self.save_accessibility_tree = save_accessibility_tree
self.force_device_scale = force_device_scale
self.window_width = window_width
self.window_height = window_height
self.fix_box_color = fix_box_color
self.llm = llm
self.testing = testing
self.benchmark = benchmark

Check warning on line 81 in agential/agents/computer_use/webvoyager_baseline/agent.py

View check run for this annotation

Codecov / codecov/patch

agential/agents/computer_use/webvoyager_baseline/agent.py#L74-L81

Added lines #L74 - L81 were not covered by tests
Expand Down Expand Up @@ -162,13 +142,14 @@ def get_fewshots(
return {"benchmark": benchmark, "fewshot_type": fewshot_type}

Check warning on line 142 in agential/agents/computer_use/webvoyager_baseline/agent.py

View check run for this annotation

Codecov / codecov/patch

agential/agents/computer_use/webvoyager_baseline/agent.py#L142

Added line #L142 was not covered by tests

def generate(

Check warning on line 144 in agential/agents/computer_use/webvoyager_baseline/agent.py

View check run for this annotation

Codecov / codecov/patch

agential/agents/computer_use/webvoyager_baseline/agent.py#L144

Added line #L144 was not covered by tests
self, instruction: str, obs: Dict[str, Any], prompt: str = ""
self, obs: Dict[str, Any], task: Dict[str, Any], prompt: str = ""
) -> WebVoyagerBaseOutput:
"""Processes a given instruction and observations to generate a response.
Args:
instruction (str): Instruction for the agent.
obs (Dict): Observations from the environment.
obs (Dict[str, Any]): Observations from the environment.
task (Dict[str, Any]): Task to generate action for.
prompt (str, optional): Predefined prompt for the agent. Defaults to "".
Returns:
Expand All @@ -182,20 +163,12 @@ def generate(
webvoyager_base_output: WebVoyagerBaseOutput = self.strategy.generate(

Check warning on line 163 in agential/agents/computer_use/webvoyager_baseline/agent.py

View check run for this annotation

Codecov / codecov/patch

agential/agents/computer_use/webvoyager_baseline/agent.py#L163

Added line #L163 was not covered by tests
system_prompt=system_prompt,
system_prompt_text_only=system_prompt_text_only,
output_dir=self.output_dir,
download_dir=self.download_dir,
test_file=self.test_file,
max_iter=self.max_iter,
seed=self.seed,
max_attached_imgs=self.max_attached_imgs,
temperature=self.temperature,
text_only=self.text_only,
headless=self.headless,
save_accessibility_tree=self.save_accessibility_tree,
force_device_scale=self.force_device_scale,
window_width=self.window_width,
window_height=self.window_height,
fix_box_color=self.fix_box_color,
task=task,
obs=obs
)

return webvoyager_base_output

Check warning on line 174 in agential/agents/computer_use/webvoyager_baseline/agent.py

View check run for this annotation

Codecov / codecov/patch

agential/agents/computer_use/webvoyager_baseline/agent.py#L174

Added line #L174 was not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any, Dict, TypedDict

from selenium import webdriver
from selenium.webdriver.remote.webdriver import WebDriver

Check warning on line 8 in agential/agents/computer_use/webvoyager_baseline/functional_webarena.py

View check run for this annotation

Codecov / codecov/patch

agential/agents/computer_use/webvoyager_baseline/functional_webarena.py#L8

Added line #L8 was not covered by tests


class AccessibilityTreeNode(TypedDict):
Expand Down Expand Up @@ -102,7 +103,7 @@ class BrowserInfo(TypedDict):

def fetch_browser_info(
# page: Page,
browser: webdriver,
browser: WebDriver,
) -> BrowserInfo:
"""Fetches detailed information about the browser state, including the DOM tree
and window configuration.
Expand Down
Loading

0 comments on commit 958190d

Please sign in to comment.