Interaction Loop
This section explains how to create an interaction loop in Colang 2.0.
Usage
In various LLM-based applications, there is a need for the LLM to keep interacting with the user in a continuous interaction loop. The example below shows how a simple interaction loop can be implemented using the while construct and how the bot can be proactive when the user is silent.
examples/v2_x/tutorial/interaction_loop/main.co
The main flow above activates the generating user intent for unhandled user utterance flow from the avatars module, which uses the LLM to generate the canonical form for a user message (a.k.a., the user intent). Also, when the LLM generates an intent that is not handled by the Colang script, the unhandled user intent flow is triggered (line 11).
Line 14 in the example above shows how to use the pre-defined user silent event to model time-driven interaction.
This example also uses the when / or when syntax, which is a mechanism for branching a flow on multiple paths. When a flow reaches a branching point, it will start monitoring all the branches and continue the interaction as soon as a branch is matched.
Testing
The next example will show you how to create LLM-driven flows.