mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-08-11 09:25:42 +00:00
fix: make browser agent compatible with PlayWright 1.50 (#381)
Co-authored-by: Rafael Uzarowski <uzarowski.rafael@proton.me>
This commit is contained in:
parent
6eeb706cb1
commit
ace6dccfca
3 changed files with 35 additions and 17 deletions
|
|
@ -5,13 +5,13 @@ from agent import Agent, InterventionException
|
|||
|
||||
import models
|
||||
from python.helpers.tool import Tool, Response
|
||||
from python.helpers import dirty_json, files, rfc_exchange, defer, strings, persist_chat
|
||||
from python.helpers.print_style import PrintStyle
|
||||
from python.helpers import files, defer, persist_chat
|
||||
from python.helpers.browser_use import browser_use
|
||||
from python.extensions.message_loop_start._10_iteration_no import get_iter_no
|
||||
from pydantic import BaseModel
|
||||
import uuid
|
||||
|
||||
from python.helpers.dirty_json import DirtyJson
|
||||
from langchain_core.messages import SystemMessage
|
||||
|
||||
class State:
|
||||
@staticmethod
|
||||
|
|
@ -83,10 +83,10 @@ class State:
|
|||
await self._initialize()
|
||||
|
||||
class CustomSystemPrompt(browser_use.SystemPrompt):
|
||||
def important_rules(self) -> str:
|
||||
existing_rules = super().important_rules()
|
||||
def get_system_message(self) -> SystemMessage:
|
||||
existing_rules = super().get_system_message().text()
|
||||
new_rules = agent.read_prompt("prompts/browser_agent.system.md")
|
||||
return f"{existing_rules}\n{new_rules}".strip()
|
||||
return SystemMessage(content=f"{existing_rules}\n{new_rules}".strip())
|
||||
|
||||
# Model of task result
|
||||
class DoneResult(BaseModel):
|
||||
|
|
@ -183,7 +183,7 @@ class BrowserAgent(Tool):
|
|||
result = await task.result()
|
||||
answer = result.final_result()
|
||||
try:
|
||||
answer_data = dirty_json.DirtyJson.parse_string(answer)
|
||||
answer_data = DirtyJson.parse_string(answer)
|
||||
answer_text = strings.dict_to_text(answer_data) # type: ignore
|
||||
except Exception as e:
|
||||
answer_text = answer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue