import coreimport llmflow main activate llm continuation activate greetingflow greeting user expressed greeting bot express greetingflow user expressed greeting user said "hi" or user said "hello"flow bot express greeting bot say "Hello world!"
What changed:
import llm: Adds LLM capabilities
activate llm continuation: Enables the LLM to generate responses
activate greeting: Makes the greeting flow active
Separate intent flows: user expressed greeting and bot express greeting define intents
From examples/v2_x/tutorial/interaction_loop/main.co:
flow main match UtteranceUserAction.Finished(final_transcript="Hi") start UtteranceBotAction(script="Hi there! How are you?") as $ref_action_1 match $ref_action_1.Finished() match UtteranceUserAction.Finished(final_transcript="Good and you?") start UtteranceBotAction(script="Great! Thanks") as $ref_action_2 start GestureBotAction(gesture="Thumbs up") as $ref_action_3 match $ref_action_2.Finished() and $ref_action_3.Finished()
Key features:
Action matching: match UtteranceUserAction.Finished()
Flow references: as $ref_action_1 stores a reference
Parallel actions: Both $ref_action_2 and $ref_action_3 start simultaneously
From examples/v2_x/tutorial/guardrails_1/rails.co:
import coreimport guardrailsimport llmflow main activate llm continuation activate greetingflow greeting user expressed greeting bot express greetingflow user expressed greeting user said "hi" or user said "hello"flow bot express greeting bot say "Hello world!"flow input rails $input_text $input_safe = await check user utterance $input_text if not $input_safe bot say "I'm sorry, I can't respond to that." abortflow check user utterance $input_text -> $input_safe $is_safe = ..."Consider the following user utterance: '{$input_text}'. Assign 'True' if appropriate, 'False' if inappropriate." print $is_safe return $is_safe
Key features:
import guardrails: Loads guardrails support
input rails flow: Special flow called for every user input
Generation operator (...): Uses LLM to evaluate safety
Use the global keyword for variables shared across flows:
flow main global $user_authenticated = False activate authenticationflow authentication global $user_authenticated user provided credentials $user_authenticated = True
Here’s a complete bot with greeting, capabilities, and safety:
import coreimport llmimport guardrailsflow main activate llm continuation activate greeting activate capabilitiesflow greeting user expressed greeting bot express greetingflow capabilities user asked capabilities bot explain capabilitiesflow user expressed greeting user said "hi" or user said "hello" or user said "hey"flow user asked capabilities user said "what can you do" or user said "help"flow bot express greeting bot say "Hello! I'm your assistant."flow bot explain capabilities bot say "I can answer questions and help you with various tasks. Just ask!"flow input rails $input_text $is_safe = ..."Is this appropriate: '{$input_text}'? Return True or False." if not $is_safe bot say "I can't respond to that." abort