Closed efrat-deepkeep closed 4 months ago
Hi @efrat-deepkeep, thanks for opening this issue.
You can use
import core
flow main
start CustomAsyncTestAction(value=5) as $action_ref
match $action_ref.Finished()
bot say "The result is: {$action_ref.return_value}"
match RestartEvent()
you can read more about it at NeMo Guardrails official documentation.
This is low level, you can do
import core
flow main
$result = await CustomAsyncTestAction(value=5)
bot say "The result is: {$result}"
Hope it answers your question.
thank you!
Hi, I too tried to use Colang 2.0 recently and implemented the simple tutorial script provided by NeMo guardrails for using async python actions.
main.co file looks like this: import core flow main start CustomAsyncTestAction(value=5) as $action_ref await $action_ref.Finished() as $event_ref bot say "The result is: {$event_ref.return_value}"
actions.py file looks like this: from nemoguardrails.actions import action
@action(name="CustomAsyncTestAction", execute_async=True) async def custom_test(value: int): return value
When I run the code i get the following error: /nemoguardrails/colang/v2_x/lang/expansion.py, line 478, in _expand_await_element raise ColangSyntaxError(f"Unsupported spec type '{type(element.spec)}'") nemoguardrails.colang.v2_x.runtime.errors.ColangSyntaxError: Unsupported spec type '<class 'nemoguardrails.colang.v2_x.lang.colang_ast.Spec'>'
Does anyone know why? What would be the correct way to call an asynchronous function from a colang flow?
Thank you!