This is the generated Deep Research Report. Would you help buy me a coffee/tip me/send me a red envelop?
You have consumed xxx tokens, xxx images
' consumption_chunk = json.dumps( assembly_message("assistant", OUTPUT_FORMAT_HTML, consumption_html, content_type=CONTENT_TYPE_HTML, section="", message_id=message_id, template=TEMPLATE_STREAMING_CONTENT_TYPE)) # 2. Create order and insert db order = payment_agent.create_order(amount, currency) order_id = order.get(ORDER_ID, str(uuid.uuid4())) payment_agent.orders[order_id]["event"] = asyncio.Event() # 3. Create payment intent and return checkout card html/js checkout_result = payment_agent.checkout(payment_method="all", order_id=order_id, amount=amount, currency=currency) checkout_html = checkout_result.get("checkout_html", "") checkout_js = checkout_result.get("checkout_js", "") content_type_chunk = json.dumps( assembly_message("assistant", OUTPUT_FORMAT_HTML, checkout_html, content_type=CONTENT_TYPE_HTML, section="", message_id=message_id, template=TEMPLATE_STREAMING_CONTENT_TYPE)) js_chunk = json.dumps( assembly_message("assistant", OUTPUT_FORMAT_HTML, checkout_js, content_type=CONTENT_TYPE_JS, section="", message_id=message_id, template=TEMPLATE_STREAMING_CONTENT_TYPE)) # 4. Stream events to front-end chunk_list = [consumption_chunk, content_type_chunk, js_chunk] generator = payment_stream_generator( order_id, message_id, chunk_list, payment_agent.orders ) return generator ``` #### **E-Commerce Checkout** Description: This scenario focuses on agent assistance in user transactions. The agent's task is to guide the user through an external e-commerce website and automatically identify and highlight the final payment entry or checkout confirmation element. The agent simplifies the transaction completion process by pointing the user to the precise Call to Action required to finalize the purchase. ``` # workflow/ecommerce_checkout.py import json import uuid import asyncio from typing import Dict, Any, List from constants import * from utils import assembly_message, get_new_message_id async def run_ecommerce_checkout_loop( messages: List[Dict], kwargs: Dict[str, Any], payment_agent: Any, payment_stream_generator: Any, default_price: float = 120.00, default_currency: str = "USD" ): """ Implements the E-Commerce Checkout scenario. 1. Agent summarizes the final cart/order details. 2. Stream the summary and offer the A2Z credit/unified payment option. 3. Gated: Wait for payment to be confirmed (e.g., using A2Z credit deduction). 4. If paid, confirm the e-commerce transaction completion. """ message_id = get_new_message_id() # 1. Agent summarizes the e-commerce cart/order amount = default_price currency = default_currency cart_summary = f"""
Product: Blue Coat (Brand: XXX)
Total: **{currency} {amount:,.2f}**
Please use the available payment options to finalize your order with the E-Commerce site.