Skip to content

Commit

Permalink
Revert "🕸️ Ensure URL check works"
Browse files Browse the repository at this point in the history
This reverts commit b5dcc63.
  • Loading branch information
asim-shrestha committed Nov 20, 2023
1 parent b5dcc63 commit e5d5994
Show file tree
Hide file tree
Showing 10 changed files with 27,929 additions and 14 deletions.
15 changes: 15 additions & 0 deletions bananalyzer/data/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,21 @@
}
]
},
{
"id": "8fc4b97d-f823-4c31-b50f-ad42671fe2b1",
"url": "https://www.shrinerschildrens.org/en/locations?listPage=1",
"source": "hosted",
"domain": "healthcare",
"subdomain": "contact",
"type": "navigate",
"goal": "You are currently on a listing page. Use pagination controls to travel to the last available listing page if possible ",
"evals": [
{
"type": "end_url_match",
"expected": "https://www.shrinerschildrens.org/en/locations?listPage=4"
}
]
},
{
"id": "b572a5e4-717b-41ab-86e3-ec41cac368b3",
"url": "https://www.sih.net/locations?page=1&perpage=25&q=&serv=&dist=&zip=&sort=Ascending&view=list",
Expand Down
6 changes: 3 additions & 3 deletions bananalyzer/runner/agent_runner.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Union

from playwright.async_api import Page
from playwright.async_api import BrowserContext

from bananalyzer.data.schemas import Example

AgentResult = Union[Dict[str, Any], List[Dict[str, Any]], List[str], str]
AgentResult = Union[Dict[str, Any], List[Dict[str, Any]], str]


class AgentRunner(ABC):
Expand All @@ -16,7 +16,7 @@ class AgentRunner(ABC):
@abstractmethod
async def run(
self,
page: Page,
browser_context: BrowserContext,
eval_context: Example,
) -> AgentResult:
pass
12 changes: 4 additions & 8 deletions bananalyzer/runner/null_agent_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio

from playwright.async_api import Page
from playwright.async_api import BrowserContext

from bananalyzer.data.schemas import Example
from bananalyzer.runner.agent_runner import AgentResult, AgentRunner
Expand All @@ -13,16 +13,12 @@ class NullAgentRunner(AgentRunner):

async def run(
self,
page: Page,
context: BrowserContext,
example: Example,
) -> AgentResult:
page = await context.new_page()
print(f"Testing {example.get_static_url()}")
await page.goto(example.get_static_url())
await asyncio.sleep(0.5)
print(f"Done testing {example.get_static_url()}")

# Ensure page is correct
if example.evals[0].type == "end_url_match":
await page.goto(example.evals[0].expected)

return example.evals[0].expected
return example.evals[0].expected # type: ignore
5 changes: 2 additions & 3 deletions bananalyzer/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ async def test_{example.id.replace("-", "_")}() -> None:
async with async_playwright() as p:
browser = await p.chromium.launch(headless={headless})
context = await browser.new_context()
page = await context.new_page()
example = get_example_by_url("{example.url}")
# The agent is imported into the global context prior to this call
result = await agent.run(page, example)
result = await agent.run(context, example)
for curr_eval in example.evals:
curr_eval.eval_results(page, result)
curr_eval.eval_results(p, result)
""",
example=example,
)
Expand Down
Empty file added bananalyzer/server/__init__.py
Empty file.
27,903 changes: 27,903 additions & 0 deletions python/bananalyzer/data/f514aa3b-4333-46b6-9d6a-14678632beae/index.mhtml

Large diffs are not rendered by default.

File renamed without changes.
2 changes: 2 additions & 0 deletions tests/fixtures/agent_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def TestAgentWrapper(AgentWrapper):
pass
File renamed without changes.
File renamed without changes.

0 comments on commit e5d5994

Please sign in to comment.