from askui import VisionAgent, ResponseSchemaBasefrom typing import Listclass Entry(ResponseSchemaBase): company: str contact: str country: strclass Table(ResponseSchemaBase): rows: List[Entry]with VisionAgent() as agent: agent.tools.webbrowser.open_new("https://www.w3schools.com/html/html_tables.asp") agent.wait(3) # Wait for page to load result = agent.get("Can you extract me the table?", response_schema=Table) print(result.model_dump_json(indent=2))
Match Schema to Table Structure: Design your Pydantic model to match the actual table columns
Copy
Ask AI
# Look at the table firstheaders = agent.get("What are the table headers?", response_schema=List[str])print(f"Table columns: {headers}")# Then design your model accordingly
Type Conversion: Specify correct types for numeric columns
Copy
Ask AI
class DataRow(ResponseSchemaBase): product: str quantity: int # Will convert "5" to 5 price: float # Will convert "$9.99" to 9.99