PathOnAI / LiteWebAgent

The Library for LLM-based web-agent applications
Other
33 stars 6 forks source link

fix error #117

Open danni-z-loggia opened 2 hours ago

danni-z-loggia commented 2 hours ago
[{'action': "```click('1428')```", 'prob': 0.95}, {'action': "To search for a bag of dog food, I need to enter the search term in the search box.\n\n```fill('171', 'dog food')```", 'prob': 0.05}]
2024-11-14 18:02:03,305 - litewebagent.action.utils - INFO - {'text': '', 'type': None, 'tag': 'a', 'id': None, 'href': '/b/ref=s9_acss_bw_cg_static_2a1_w/ref=s9_acss_bw_cg_cattile_2a1_w?node=2975359011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=merchandised-search-4&pf_rd_r=T8KTHWFWZJRK48CQF235&pf_rd_t=101&pf_rd_p=597d1609-b06a-4f70-9616-7669de57ae00&pf_rd_i=2975312011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=merchandised-search-8&pf_rd_r=G596TSVMYEYCX0MGT7CS&pf_rd_t=101&pf_rd_p=f197d4a9-3a9b-45af-bbe6-3988f514671f&pf_rd_i=2619533011', 'title': None, 'ariaLabel': 'Dog Food', 'name': None, 'value': None, 'placeholder': None, 'class': None, 'role': None, 'action': "```click('1428')```", 'url': 'https://www.amazon.com/pet-shops-dogs-cats-hamsters-kittens/b/?ie=UTF8&node=2619533011&ref_=nav_cs_pets', 'task_description': 'Search for a bag of dog food.'}
2024-11-14 18:02:03,305 - litewebagent.action.utils - INFO - Executing action script
click('1428')
Entering get_elem_by_bid with bid: 1428
Current frame: <Page url='https://www.amazon.com/pet-shops-dogs-cats-hamsters-kittens/b/?ie=UTF8&node=2619533011&ref_=nav_cs_pets'>
Locating final element with bid: 1428
Element found: <Locator frame=<Frame name= url='https://www.amazon.com/pet-shops-dogs-cats-hamsters-kittens/b/?ie=UTF8&node=2619533011&ref_=nav_cs_pets'> selector='internal:testid=[data-unique-test-id="1428"s]'>
done extracting element
Attempting to click element with bid: 1428
Attempt 1 of 3
Locating element
Entering get_elem_by_bid with bid: 1428
Current frame: <Page url='https://www.amazon.com/pet-shops-dogs-cats-hamsters-kittens/b/?ie=UTF8&node=2619533011&ref_=nav_cs_pets'>
Locating final element with bid: 1428
Element found: <Locator frame=<Frame name= url='https://www.amazon.com/pet-shops-dogs-cats-hamsters-kittens/b/?ie=UTF8&node=2619533011&ref_=nav_cs_pets'> selector='internal:testid=[data-unique-test-id="1428"s]'>
Element found: <Locator frame=<Frame name= url='https://www.amazon.com/pet-shops-dogs-cats-hamsters-kittens/b/?ie=UTF8&node=2619533011&ref_=nav_cs_pets'> selector='internal:testid=[data-unique-test-id="1428"s]'>
Checking if element is clickable
Element is clickable
Adding demo mode effects
Demo mode effects added
Performing click with timeout 30000ms
Click performed successfully
Timeout error on attempt 1: Timeout 30000ms exceeded.
=========================== logs ===========================
"domcontentloaded" event fired
"load" event fired
============================================================
2024-11-14 18:02:40,507 - litewebagent.tools.shared_utils - ERROR - Action execution failed: TypeError: 'str' object is not callable
2024-11-14 18:02:40,507 - litewebagent.agents.FunctionCallingAgents.BaseAgent - INFO - function name: navigation, function args: {'task_description': 'Search for a bag of dog food.'}
2024-11-14 18:02:40,507 - litewebagent.agents.FunctionCallingAgents.BaseAgent - INFO - function name: navigation, function response Task failed with action error: TypeError: 'str' object is not callable
2024-11-14 18:02:41,347 - httpx - INFO - HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
danni-z-loggia commented 2 hours ago
click('67')
Entering get_elem_by_bid with bid: 67
Current frame: <Page url='https://www.amazon.com/'>
Locating final element with bid: 67
Element found: <Locator frame=<Frame name= url='https://www.amazon.com/'> selector='internal:testid=[data-unique-test-id="67"s]'>
done extracting element
Attempting to click element with bid: 67
Attempt 1 of 3
Locating element
Entering get_elem_by_bid with bid: 67
Current frame: <Page url='https://www.amazon.com/'>
Locating final element with bid: 67
Element found: <Locator frame=<Frame name= url='https://www.amazon.com/'> selector='internal:testid=[data-unique-test-id="67"s]'>
Element found: <Locator frame=<Frame name= url='https://www.amazon.com/'> selector='internal:testid=[data-unique-test-id="67"s]'>
Checking if element is clickable
Element is clickable
Adding demo mode effects
Demo mode effects added
Performing click with timeout 30000ms
Click performed successfully
Timeout error on attempt 1: Timeout 30000ms exceeded.
=========================== logs ===========================
"domcontentloaded" event fired
"load" event fired
============================================================
Traceback (most recent call last):
  File "<string>", line 425, in click
  File "/Users/danqingzhang/Desktop/LiteWebAgent/venv/lib/python3.11/site-packages/playwright/sync_api/_generated.py", line 9412, in wait_for_load_state
    self._sync(self._impl_obj.wait_for_load_state(state=state, timeout=timeout))
  File "/Users/danqingzhang/Desktop/LiteWebAgent/venv/lib/python3.11/site-packages/playwright/_impl/_sync_base.py", line 109, in _sync
    return task.result()
           ^^^^^^^^^^^^^
  File "/Users/danqingzhang/Desktop/LiteWebAgent/venv/lib/python3.11/site-packages/playwright/_impl/_page.py", line 489, in wait_for_load_state
    return await self._main_frame.wait_for_load_state(**locals_to_params(locals()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danqingzhang/Desktop/LiteWebAgent/venv/lib/python3.11/site-packages/playwright/_impl/_frame.py", line 236, in wait_for_load_state
    return await self._wait_for_load_state_impl(state, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danqingzhang/Desktop/LiteWebAgent/venv/lib/python3.11/site-packages/playwright/_impl/_frame.py", line 264, in _wait_for_load_state_impl
    await wait_helper.result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
"domcontentloaded" event fired
"load" event fired
============================================================

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/danqingzhang/Desktop/LiteWebAgent/prompting_main.py", line 44, in <module>
    main(args)
  File "/Users/danqingzhang/Desktop/LiteWebAgent/prompting_main.py", line 19, in main
    response = agent.send_prompt(args.plan)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danqingzhang/Desktop/LiteWebAgent/litewebagent/agents/PromptAgents/PromptAgent.py", line 21, in send_prompt
    trajectory = self.send_completion_request(plan, 0, [])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danqingzhang/Desktop/LiteWebAgent/litewebagent/agents/PromptAgents/PromptAgent.py", line 84, in send_completion_request
    return self.send_completion_request(plan, depth + 1, trajectory)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danqingzhang/Desktop/LiteWebAgent/litewebagent/agents/PromptAgents/PromptAgent.py", line 65, in send_completion_request
    execute_action(next_action, self.action_set, page, context, self.goal, page_info['interactive_elements'],
  File "/Users/danqingzhang/Desktop/LiteWebAgent/litewebagent/action/utils.py", line 29, in execute_action
    execute_python_code(
  File "/Users/danqingzhang/Desktop/LiteWebAgent/litewebagent/action/base.py", line 63, in execute_python_code
    exec(code, globals)
  File "<string>", line 760, in <module>
  File "<string>", line 432, in click
TypeError: 'str' object is not callable
TataKKKL commented 1 hour ago

https://github.com/PathOnAI/LiteWebAgent/commit/8d6c98d91b70ed779ed527f95d61aed0d70060f5