Client delegation
In this lesson, we’ll look at client delegation. With client delegation, your application handles the back and forth between GPT-Live and your backend.
This is useful when you want to connect GPT-Live to an agent you’ve already built or control what context your application sends to the backend and what it returns to GPT-Live.
Let’s look at a delivery application that uses client delegation with GPT-Live to follow a standard operating procedure (SOP) and take orders.
Let’s walk through how it works.
Let’s say we already have an order agent that takes delivery orders. Its prompt includes a standard operating procedure (SOP), and it has access to three tools on our server: one to calculate the order total, one to check delivery availability, and one to place an approved order.
Browser
Server
Order agent
modelgpt-6-lunainstructions
Looks up each item in the menu, multiplies its price by the quantity, and adds sales tax and the delivery fee. The quote is valid for 15 minutes.
itemsarray of objectsThe items in the order. Each object contains:
skustringMenu item ID
quantityinteger1–8 units
spicestringmild, medium, or hot; required for entrées, omitted otherwise
An itemized quote with quote_id, items, subtotal, tax, delivery_fee, total, and expires_at.
Checks the restaurant’s delivery schedule for capacity at the requested time. If that window is full, it offers the next available one. It does not reserve a slot.
requested_timestringLocal time in HH:MM format, or asap
requested_time_available and slot, which contains slot_id, start, and end. The slot is null if no window is available.
Verifies the customer approved the current quote, checks that the delivery slot still has capacity, then reserves it and records the order and kitchen ticket.
quote_idstringThe current approved price quote
slot_idstringThe selected delivery window
delivery_addressstringThe customer’s approved address
The confirmation: order_id, quote_id, status, total, and estimated_delivery.
GPT-Live
For more details, see the cookbook on building a voice agent that follows an SOP.
Try it yourself
Use the prompt below to build your own voice agent and follow the delegation as you talk to it.