chore(browser_use_tool): fix code style according to pre-commit

This commit is contained in:
Sheng Fan 2025-03-09 11:30:41 +08:00
parent 7090490f75
commit 0d0f8ab233

View File

@ -11,6 +11,7 @@ from pydantic_core.core_schema import ValidationInfo
from app.tool.base import BaseTool, ToolResult
_BROWSER_DESCRIPTION = """
Interact with a web browser to perform various actions such as navigation, element interaction,
content extraction, and tab management. Supported actions include:
@ -173,23 +174,23 @@ class BrowserUseTool(BaseTool):
elif action == "screenshot":
screenshot = await context.take_screenshot(full_page=True)
return ToolResult(
output=
f"Screenshot captured (base64 length: {len(screenshot)})",
output=f"Screenshot captured (base64 length: {len(screenshot)})",
system=screenshot,
)
elif action == "get_html":
html = await context.get_page_html()
truncated = html[:2000] + "..." if len(
html) > 2000 else html
truncated = html[:2000] + "..." if len(html) > 2000 else html
return ToolResult(output=truncated)
elif action == "get_text":
text = await context.execute_javascript('document.body.innerText')
text = await context.execute_javascript("document.body.innerText")
return ToolResult(output=text)
elif action == "read_links":
links = await context.execute_javascript("document.querySelectorAll('a[href]').forEach((elem) => {if (elem.innerText) {console.log(elem.innerText, elem.href)}})")
links = await context.execute_javascript(
"document.querySelectorAll('a[href]').forEach((elem) => {if (elem.innerText) {console.log(elem.innerText, elem.href)}})"
)
return ToolResult(output=links)
elif action == "execute_js":