Preparing requests in advance
Put the unchanging parts first so the server can prepare them before the changing part arrives.
Most applications send nearly the same request over and over: the same company and team list, the same screen and buttons, the same tools. Only one field changes, such as the ticket text or the voice transcript. A Jeff server can prepare the unchanging start of a request once and reuse it, so each real request only has to process the part that changed.
Order the request for it
- State: the unchanging fields first, the one changing field last. Every adapter's page marks which field changes.
- Options: the options that never change first, word for word (for example
other, orask_questionandnone_of_these), then the ones that do. - Instructions: the same wording every time.
Keep the order the adapter's page shows: each adapter was trained with its state fields in that order.
Prepare while you wait
prepare sends the request with the changing field empty and drops the answer. Call it as soon as the fixed part is
known: when a screen opens, or when a ticket queue is loaded.
const screen = { current_screen: 'Inbox', previous_screen: 'All deals' };
const fixed = { ask_question: 'The user is asking a question', none_of_these: 'None of these' };
// The screen opened: prepare while the user is still speaking.
await jeff.prepare({ ...screen, voice_transcript_may_contain_errors: '' }, { command: choiceQuestion(fixed, 'What does the user want?') });
// The user spoke.
const picked = await jeff.choose(
{ ...screen, voice_transcript_may_contain_errors: 'open the email from Sarah' },
{ ...fixed, o1: 'Open the latest email', o2: 'Archive this thread', o3: 'Go back' },
'What does the user want?',
);In Python the call is the same: jeff.prepare(state, questions).
Next: Data guidelines
