Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ccl cleanup #461

Merged
merged 21 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
62ddce7
Cleanup llm core flows
schuellc-nvidia Apr 15, 2024
48ccf3d
Redistributed more flows from avatars.co to other standard library mo…
schuellc-nvidia Apr 15, 2024
6821e58
Merge remote-tracking branch 'origin/develop' into feature/ccl-cleanup
schuellc-nvidia Apr 15, 2024
35113ea
Fix unsupported flow return value
schuellc-nvidia Apr 16, 2024
5d5dce5
Increase time threshold of state serialization unit test
schuellc-nvidia Apr 16, 2024
7fff1f4
Fix Colang variable highlighting
schuellc-nvidia Apr 16, 2024
2864455
Fix `or when` parsing
schuellc-nvidia Apr 18, 2024
074f207
Add support for `pass` statement to syntax highlighting
schuellc-nvidia Apr 18, 2024
be90501
Add support for action/intent flow marking
schuellc-nvidia Apr 18, 2024
832f13c
Refactor Colang standard library and related examples
schuellc-nvidia Apr 18, 2024
3fe4e2c
Add return value for user utterance flows
schuellc-nvidia Apr 18, 2024
cd97ce8
Merge remote-tracking branch 'origin/develop' into feature/ccl-cleanup
schuellc-nvidia Apr 18, 2024
daa17f7
Minor formatting fix
schuellc-nvidia Apr 18, 2024
d445f94
Adjust time threshold for serialization test
schuellc-nvidia Apr 19, 2024
038ffbd
Adjust time threshold for serialization test
schuellc-nvidia Apr 19, 2024
f998b36
Add default simple eval functions
schuellc-nvidia Apr 19, 2024
df5367c
Rename `orwhen` to `or when`
schuellc-nvidia Apr 19, 2024
9a8b1c2
Remove some meta tag comments and turned them into decorators
schuellc-nvidia Apr 19, 2024
b8004fe
Some language reference example fixes
schuellc-nvidia Apr 19, 2024
1334b0c
Resolve pre-commit issues
schuellc-nvidia Apr 19, 2024
568bc02
Update language reference examples in section `defining flows`
schuellc-nvidia Apr 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
flow main
# Start and wait for a flow in two steps using a flow reference
start bot express greeting as $flow_ref
match $flow_ref.Finished()

# Start and wait for a flow to finish
await bot express greeting

# Or without the optional await keyword
bot express greeting

match RestartEvent()

flow bot express greeting
await UtteranceBotAction(script="Hi")
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
flow main
start pattern a
start pattern b
match RestartEvent()

flow pattern a
user said something
bot say "Hi"
user said "How are you?"
bot say "Great!"

flow pattern b
user said something
bot say "Hi"
user said something
bot say "Bad!"

flow user said $text
match UtteranceUserAction.Finished(final_transcript=$text)

flow user said something
match UtteranceUserAction.Finished()

flow bot say $text
await UtteranceBotAction(script=$text)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
flow main
start pattern a as $flow_ref_a
start pattern b as $flow_ref_b
match $flow_ref_a.Finished() and $flow_ref_b.Finished()
await UtteranceBotAction(script="End")
match RestartEvent()

flow pattern a
match UtteranceUserAction.Finished(final_transcript="Bye")
await UtteranceBotAction(script="Goodbye") as $action_ref

flow pattern b
match UtteranceUserAction.Finished(final_transcript="Hi")
await UtteranceBotAction(script="Hello")
match UtteranceUserAction.Finished(final_transcript="Bye")
await UtteranceBotAction(script="Goodbye") as $action_ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
flow main
start pattern a as $flow_ref_a
start pattern b as $flow_ref_b
match $flow_ref_a.Finished() and $flow_ref_b.Finished()
bot say "End"
match RestartEvent()

flow pattern a
user said "Bye"
bot say "Goodbye"

flow pattern b
user said "Hi"
bot say "Hello"
user said "Bye"
bot say "Goodbye"

flow user said $text
match UtteranceUserAction.Finished(final_transcript=$text)

flow bot say $text
await UtteranceBotAction(script=$text)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
flow main
match UserReadyEvent()
bot express greeting

flow bot express greeting
start bot say "Hi!" as $flow_ref
start bot gesture "wave with one hand"
match $flow_ref.Finished()

flow bot say $text
await TimerBotAction(timer_name="utterance_timer", duration=2.0)
await UtteranceBotAction(script=$text)

flow bot gesture $gesture
await TimerBotAction(timer_name="gesture_timer", duration=1.0)
await GestureBotAction(gesture=$gesture)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
10 changes: 10 additions & 0 deletions examples/v2_x/language_reference/defining_flows/start_flow/main.co
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
flow main
start bot handle user welcoming
match RestartEvent() # <- This statement is only processed once the previous flow has started

flow bot handle user welcoming
start UtteranceBotAction(script="Hi")
start GestureBotAction(gesture="Wave") as $action_ref
match $action_ref.Finished() # <- At this point the flow is considered to have started
match UtteranceUserAction().Finished()
start UtteranceBotAction(script="How are you?")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
flow main
activate catching of undefined flow start
bot solve all your problems
match RestartEvent()

flow catching of undefined flow start
match UnhandledEvent(event="StartFlow") as $event
bot say "Cannot start the undefined flow: '{$event.flow_id}'!"
# We need to abort the flow that sent the FlowStart event since it might be waiting for it
send StopFlow(flow_instance_uid=$event.source_flow_instance_uid)

flow bot say $text
await UtteranceBotAction(script=$text)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flow main
send StartUtteranceBotAction(script="Hi") and StartGestureBotAction(gesture="Wave")
send StartGestureBotAction(gesture="Ping") or StartGestureBotAction(gesture="Pong")
match RestartEvent()
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flow main
match UtteranceUserActionFinished() as $event_ref
send StartUtteranceBotAction(script=$event_ref.arguments.final_transcript)
send StartUtteranceBotAction(script=$event_ref.final_transcript)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colang_version: "2.x"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flow main
match Event(param=42)
send StartUtteranceBotAction(script="Success")
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flow main
match Event1(param=r"(?i)test.*")
match Event(param=regex("(?i)test.*"))
send StartUtteranceBotAction(script="Success 1")
match Event1(param=r"1\d*0")
match Event(param=regex("1\d*0"))
send StartUtteranceBotAction(script="Success 2")
match Event1(param=["a",r".*","b"])
match Event(param=["a",regex(".*"),"b"])
send StartUtteranceBotAction(script="Success 3")
17 changes: 0 additions & 17 deletions examples/v2_x/language_reference/flows/parallel_flows/main.co

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ flow main

flow catching of undefined flows
match UnhandledEvent(event="StartFlow") as $event
bot say "Cannot start the undefined flow: '{{$event.arguments.flow_id}}'!"
bot say "Cannot start the undefined flow: '{$event.flow_id}'!"
# We need to abort the flow that sent the FlowStart event since it might be waiting for it
send StopFlow(flow_instance_uid=$event.arguments.source_flow_instance_uid)
send StopFlow(flow_instance_uid=$event.source_flow_instance_uid)

flow bot say $text
await UtteranceBotAction(script=$text)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flow main
match Event1
match InputEvent
send HelloWorld
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ flow main

while True
when user said something
generate then continue interaction
llm continue interaction
4 changes: 2 additions & 2 deletions examples/v2_x/language_reference/llm/nld_example/main.co
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
flow main
activate poll llm request response 0.5
$utterance = """Welcome the user with a short sentence"""
bot say "{{$utterance}}"
bot say $utterance
user said something

@loop("llm_response_polling")
flow poll llm request response $interval
# meta: loop_id=llm_response_polling
match StartGenerateUserIntentAction() as $event_ref
or StartGenerateFlowContinuationAction() as $event_ref
or StartGenerateFlowFromNameAction() as $event_ref
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flow main
activate track bot talking state
activate tracking bot talking state
activate poll llm request response 1.0
activate trigger user intent for unhandled user utterance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ flow main
or when user said "Bye"
bot say "Goodbye"

@loop("bot_gesture_handling")
flow handling of bot gesture reaction
# meta: loop_id=bot_gesture_handling
activate reaction of bot to user greeting
activate reaction of bot to user leaving
match WaitEvent() # We have to wait since otherwise the flow finishes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
flow main
match StartEvent()
start UtteranceBotAction(script="Hello") as $ref_action
match $ref_action.Finished()
start GestureBotAction(gesture="Wave")
Expand Down
10 changes: 9 additions & 1 deletion examples/v2_x/tutorial/interaction_loop/main.co
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import core
import avatars
import timing
import llm
import utils

flow main
activate generating user intent for unhandled user utterance
Expand All @@ -8,7 +12,7 @@ flow main
$response = i"Response to what user said."
bot say $response
or when user was silent 12.0
bot say "You can ask me anything!"
bot inform about service
or when user expressed greeting
bot say "Hi there!"
or when user expressed goodbye
Expand All @@ -22,3 +26,7 @@ flow user expressed goodbye
user said "goodbye"
or user said "I am done"
or user said "I have to go"

flow bot inform about service
bot say "You can ask me anything!"
or bot say "Just ask me something!"
2 changes: 1 addition & 1 deletion nemoguardrails/colang/v2_x/lang/grammar/colang.lark
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ _IF.1: /if/
_ELSE_IF.1: /(elif|else\s+if)/
_OR_WHEN.1: /(or ?when)/
_AND.1: /(and[ \t]|(\r?\n[\t ]*)+and[ \t])/
_OR.1: /(or[ \t]|(\r?\n[\t ]*)+or[ \t])/
_OR.1: /(or[ \t]|(\r?\n[\t ]*)+or[ \t]+(?!when))/
_IS.1: /is/
_IN.1: /in/
_NOT.1: /not/
Expand Down
Loading
Loading