agents.restaurant_finder.agent
A2UI Restaurant Finder Agent using pydantic-ai.
This agent provides restaurant search and booking functionality, generating A2UI protocol messages for rich UI rendering.
This implementation uses a hybrid approach:
- The LLM agent interprets user queries and calls tools
- The A2UI response is built programmatically from tool results
RestaurantDeps Objects
class RestaurantDeps()
Dependencies for the restaurant agent.
create_restaurant_agent
def create_restaurant_agent(base_url: str) -> Agent[RestaurantDeps, str]
Create a new restaurant agent instance with the given base URL.
run_restaurant_agent
async def run_restaurant_agent(query: str,
base_url: str = "http://localhost:8765",
max_retries: int = 2) -> dict[str, Any]
Run the restaurant agent with a query.
Arguments:
query- User's query (e.g., "Top 5 Chinese restaurants in New York")base_url- Base URL for static assetsmax_retries- Maximum number of retries on failure
Returns:
Dict containing the agent response with A2UI messages
handle_a2ui_action
async def handle_a2ui_action(
action_id: str,
context: dict[str, Any],
base_url: str = "http://localhost:8765") -> dict[str, Any]
Handle an A2UI action (button click, form submission, etc.).
Arguments:
action_id- The action identifier (e.g., "book_restaurant", "submit_booking")context- The action context with relevant database_url- Base URL for static assets
Returns:
Dict containing the agent response with A2UI messages