Extract numeric values from your UI using integer and float response schemas. This is essential for reading counts, prices, percentages, and other numeric data.
Basic Usage
from askui import VisionAgent
with VisionAgent() as agent:
agent.tools.webbrowser.open_new("http://www.example.com")
agent.wait(3)
result = agent.get("How many headings do you see?", response_schema=int)
print(f"result: {result}")
Best Practices
-
Specify Units When Relevant: Be clear about what units you expect
# Good - clear about units
price_dollars = agent.get("What is the price in dollars?", response_schema=float)
weight_kg = agent.get("What is the weight in kilograms?", response_schema=float)
# Less clear
price = agent.get("What is the price?", response_schema=float)
-
Validate Numeric Ranges: Check if values are within expected ranges
percentage = agent.get("What is the progress percentage?", response_schema=float)
# Validate percentage is between 0 and 100
assert 0 <= percentage <= 100, f"Invalid percentage: {percentage}"