The process begins when the Language Model (LLM), after analyzing the conversation, decides human intervention is necessary.
- LLM JSON Response: The LLM's decision is communicated via a JSON object. To trigger the transfer, this object contains a specific key-value pair:
{"transfer_to_human": true, "reason": "Customer is asking for a supervisor"}
. - Server-Side Trigger: The
on_llm_response_a
function indeepak/server.py
serves as the callback for all LLM responses. It parses the incoming JSON and checks for thetransfer_to_human
boolean flag. - Initiating Transfer: If the flag is
true
, the server callstrigger_human_transfer_a
(deepak/server.py:1865
). This function orchestrates the start of the handover. - State Management: The core of the server's logic relies on a global dictionary
_audio_out_leads
which maps a uniquelead_key
to aStreamState
dataclass object. Insidetrigger_human_transfer_a
:
- The call's state is