diff --git a/alumnium/alumni.py b/alumnium/alumni.py index d80af24..326a0d3 100644 --- a/alumnium/alumni.py +++ b/alumnium/alumni.py @@ -5,6 +5,7 @@ from langchain_openai import AzureChatOpenAI, ChatOpenAI from langchain_google_genai import ChatGoogleGenerativeAI +from retry import retry from selenium.webdriver.remote.webdriver import WebDriver from .agents import ActorAgent, VerifierAgent @@ -41,6 +42,7 @@ def __init__(self, driver: WebDriver, model: Model = Model.load()): def quit(self): self.driver.quit() + @retry(tries=2, delay=0.1) def do(self, goal: str): self.actor_agent.invoke(goal) diff --git a/examples/pytest/google_test.py b/examples/pytest/google_test.py index 5c59bbc..b79fa40 100644 --- a/examples/pytest/google_test.py +++ b/examples/pytest/google_test.py @@ -13,6 +13,6 @@ def test_google_search(al, driver): driver.get("https://www.google.com") - al.do("type selenium to search and press enter but do not click on anything") + al.do("search for selenium") al.check("selenium in page title") al.check("selenium.dev is present in the search results") diff --git a/poetry.lock b/poetry.lock index c5712dd..2b53b6c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -487,6 +487,17 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +[[package]] +name = "decorator" +version = "5.1.1" +description = "Decorators for Humans" +optional = false +python-versions = ">=3.5" +files = [ + {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, + {file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"}, +] + [[package]] name = "defusedxml" version = "0.7.1" @@ -1935,6 +1946,17 @@ files = [ {file = "protobuf-5.28.3.tar.gz", hash = "sha256:64badbc49180a5e401f373f9ce7ab1d18b63f7dd4a9cdc43c92b9f0b481cef7b"}, ] +[[package]] +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, +] + [[package]] name = "pyasn1" version = "0.6.1" @@ -2380,6 +2402,21 @@ files = [ [package.dependencies] requests = ">=2.0.1,<3.0.0" +[[package]] +name = "retry" +version = "0.9.2" +description = "Easy to use retry decorator." +optional = false +python-versions = "*" +files = [ + {file = "retry-0.9.2-py2.py3-none-any.whl", hash = "sha256:ccddf89761fa2c726ab29391837d4327f819ea14d244c232a1d24c67a2f98606"}, + {file = "retry-0.9.2.tar.gz", hash = "sha256:f8bfa8b99b69c4506d6f5bd3b0aabf77f98cdb17f3c9fc3f5ca820033336fba4"}, +] + +[package.dependencies] +decorator = ">=3.4.2" +py = ">=1.4.26,<2.0.0" + [[package]] name = "rsa" version = "4.9" @@ -2958,4 +2995,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "99cd8fd54456e0915ddd180fbab2f6923d6d1c064dacb7171fe37695c59bee09" +content-hash = "6e1ed6a9c821ad0ea092afe2b2e48ce49a8e9102b3c7ae21781264f1946b8010" diff --git a/pyproject.toml b/pyproject.toml index eb84089..6d4e0e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,13 +14,14 @@ langchain = "^0.3" langchain-anthropic = "^0.2" langchain-google-genai = "^2.0" langchain-openai = "^0.2" +retry = "^0.9" selenium = "^4.0" [tool.poetry.group.dev.dependencies] behave = "^1.2.6" -behave-html-pretty-formatter = "^1.12" pytest = "^8.3.3" pytest-html = "^4.1.1" +behave-html-pretty-formatter = "^1.12" [build-system] requires = ["poetry-core"]