from askui import VisionAgentwith VisionAgent() as agent: agent.tools.webbrowser.open_new("http://www.example.com") agent.wait(3) text = agent.get("What is the main heading?", response_schema=str) print(f"main heading: {text}")
Be Specific About Location: Mention where the text is located
Copy
Ask AI
# Good - specific locationheader = agent.get("What is the text in the page header?", response_schema=str)# Less specifictext = agent.get("What text is shown?", response_schema=str)
Handle Empty or Missing Text: Consider that text might not exist
Copy
Ask AI
from typing import Optional# Text might not be presentoptional_text = agent.get("What is the subtitle, if any?", response_schema=Optional[str])if optional_text: print(f"Subtitle: {optional_text}")
Clean and Validate Extracted Text: Post-process extracted text as needed
Copy
Ask AI
# Extract and clean priceprice_text = agent.get("What is the price?", response_schema=str)price_value = float(price_text.replace("$", "").replace(",", ""))