-
Notifications
You must be signed in to change notification settings - Fork 15.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community[patch]: Fix Playwright Tools bug with Pydantic schemas (#27050
) - Add tests for Playwright tools schema serialization - Introduce base empty args Input class for BaseBrowserTool Test Plan: `poetry run pytest tests/unit_tests/tools/playwright/test_all.py` Fixes #26758 --------- Co-authored-by: Erick Friis <[email protected]> Co-authored-by: Eugene Yurtsev <[email protected]>
- Loading branch information
1 parent
92024d0
commit 8180637
Showing
6 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
26 changes: 26 additions & 0 deletions
26
libs/community/tests/unit_tests/tools/playwright/test_all.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Test Playwright's Tools.""" | ||
|
||
from unittest.mock import Mock | ||
|
||
import pytest | ||
|
||
from langchain_community.agent_toolkits import PlayWrightBrowserToolkit | ||
|
||
|
||
@pytest.mark.requires("playwright") | ||
@pytest.mark.requires("bs4") | ||
def test_playwright_tools_schemas() -> None: | ||
"""Test calling 'tool_call_schema' for every tool to check to init issues.""" | ||
|
||
from playwright.sync_api import Browser | ||
|
||
sync_browser = Mock(spec=Browser) | ||
tools = PlayWrightBrowserToolkit.from_browser(sync_browser=sync_browser).get_tools() | ||
|
||
for tool in tools: | ||
try: | ||
tool.tool_call_schema | ||
except Exception as e: | ||
raise AssertionError( | ||
f"Error for '{tool.name}' tool: {type(e).__name__}: {e}" | ||
) from e |