Skip to content

Commit 92a7512

Browse files
Enable parsing of ..."<NLD>" expressions
1 parent 9e65111 commit 92a7512

File tree

8 files changed

+12
-9
lines changed

8 files changed

+12
-9
lines changed

examples/v2_x/tutorial/interaction_loop/main.co

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ flow main
99

1010
while True
1111
when unhandled user intent
12-
$response = i"Response to what user said."
12+
$response = ..."Response to what user said."
1313
bot say $response
1414
or when user was silent 12.0
1515
bot inform about service

nemoguardrails/colang/v2_x/lang/parser.py

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def _apply_pre_parsing_expansions(content: str):
5959
6060
Currently, only the "..." is expanded.
6161
"""
62+
# Replace ..."NLD" with i"NLD"
63+
content = re.sub(r"\.\.\.(['\"])(.*?)\1", r'i"\2"', content)
64+
6265
# We make sure to capture the correct indentation level and use that.
6366
content = re.sub(
6467
r"\n( +)\.\.\.",

nemoguardrails/colang/v2_x/library/llm.co

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import utils
1010
flow bot say something like $text
1111
"""Trigger a bot utterance similar to given text."""
1212
activate polling llm request response
13-
$variation = i"Return a single string that is a new variation of: {$text}"
13+
$variation = ..."Return a single string that is a new variation of: {$text}"
1414
await bot say $variation
1515

1616

tests/test_configs/multi_modal_demo_v2_x/show_cases/show_case_number_guessing_game.co

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ flow showcase number guessing game
88
"""Ask the user to guess a random number between 1 and 100; after each guess let the user know if the number was to low or high. If the user guesses the correct number, congratulate!"""
99
activate reaction bot question repetition for user silence 10
1010

11-
$random_number = i"A new random explicit integer between 1 and 100, not a function."
11+
$random_number = ..."A new random explicit integer between 1 and 100, not a function."
1212
if not is_int($random_number)
1313
$random_number = 42
1414

@@ -22,7 +22,7 @@ flow showcase number guessing game
2222
$attempts = 1
2323
while True
2424
user said something
25-
$user_number = i"Store the number the user mentioned as an integer for further processing. Set this to 'None' if the user did not mention a number."
25+
$user_number = ..."Store the number the user mentioned as an integer for further processing. Set this to 'None' if the user did not mention a number."
2626
log "extracted user number {$user_number}"
2727
if not is_int($user_number)
2828
bot express "I don't think this is a number!"

tests/test_configs/multi_modal_demo_v2_x/show_cases/show_case_proactive_turn_taking.co

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ flow showcase proactive turn taking
1010
bot inform "I am going to ask you questions and if you don't respond within 5 seconds I will repeat them."
1111

1212
while True
13-
$question = i"Ask a random question that can be answered with just yes or no."
13+
$question = ..."Ask a random question that can be answered with just yes or no."
1414
if not is_str($question)
1515
$question = "Do you like Avatars?"
1616
bot ask $question

tests/v2_x/test_run_actions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_3():
104104
flow main
105105
match UtteranceUserActionFinished(final_transcript="hi")
106106
$information = await FetchDictionaryAction()
107-
$response_to_user = i"Summarize the result from the AddItemAction call to the user: {$information}"
107+
$response_to_user = ..."Summarize the result from the AddItemAction call to the user: {$information}"
108108
bot say $response_to_user
109109
""",
110110
yaml_content="""

tests/v2_x/test_various_mechanics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ def test_generate_value_with_NLD():
705705
content = """
706706
flow main
707707
#$test = await GenerateValueAction(var_name="number", instructions="Extract the number the user guessed.")
708-
$test = i'Generate a random number'
708+
$test = ...'Generate a random number'
709709
send StartUtteranceBotAction(script="{$test}")
710710
"""
711711

vscode_extension/colang-2-lang/sample.co

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ flow this is another to continue $in_var = "default" -> $out_var_1 = "test" $out
3434

3535
# This is a comment
3636
when user said "Hi"
37-
$instruction = i'this is an instruction\n'
37+
$instruction = ...'this is an instruction\n'
3838
break
3939
or when user said something
40-
$instruction = i"this is an instruction"
40+
$instruction = ..."this is an instruction"
4141
log "Yes 'sdf'!"
4242
return
4343
or when user said something

0 commit comments

Comments
 (0)