diff --git a/examples/custom_graph_domtree.py b/examples/custom_graph_domtree.py index 5cf6443d..77aec812 100644 --- a/examples/custom_graph_domtree.py +++ b/examples/custom_graph_domtree.py @@ -145,11 +145,27 @@ subtree_dict_complex = { } } -result, execution_info = graph.execute({ - "user_prompt": "How many list items are there in the document?", - "local_dir": str(subtree_dict_simple) -}) +from playwright.sync_api import sync_playwright, Playwright + +def run(playwright: Playwright): + chromium = playwright.chromium # or "firefox" or "webkit". + browser = chromium.launch() + page = browser.new_page() + page.goto("https://www.wired.com/category/science/") + #get accessibilty tree + accessibility_tree = page.accessibility.snapshot() + + result, execution_info = graph.execute({ + "user_prompt": "List me all the latest news with their description.", + "local_dir": str(accessibility_tree) + }) + + # get the answer from the result + result = result.get("answer", "No answer found.") + print(result) + # other actions... + browser.close() + +with sync_playwright() as playwright: + run(playwright) -# get the answer from the result -result = result.get("answer", "No answer found.") -print(result)