You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to follow the documentation for calling an asynchronous function as an action.
Here is the relevant code from the docs:
in actions.py
from nemoguardrails.actions import action @action(name="CustomAsyncTestAction", execute_async=True)
async def custom_test(value: int):
return value + value
in main.co
import core
flow main
start CustomTestAction(value=5) as $action_ref
await $action_ref.Finished() as $event_ref
bot say "The result is: {$event_ref.return_value}" # Access the function return value via the event reference
This isn't working for me. I keep getting the following error:
ColangSyntaxError: Unsupported spec type '<class 'nemoguardrails.colang.v2_x.lang.colang_ast.Spec'>'
This is the traceback:
Traceback (most recent call last):
File ".../bin/nemoguardrails", line 8, in
sys.exit(app())
File ".../lib/python3.10/site-packages/typer/main.py", line 328, in call
raise e
File ".../lib/python3.10/site-packages/typer/main.py", line 311, in call
return get_command(self)(*args, **kwargs)
File ".../lib/python3.10/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File ".../lib/python3.10/site-packages/typer/core.py", line 783, in main
return _main(
File ".../lib/python3.10/site-packages/typer/core.py", line 225, in _main
rv = self.invoke(ctx)
File ".../lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File ".../lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File ".../lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File ".../lib/python3.10/site-packages/typer/main.py", line 683, in wrapper
return callback(**use_params) # type: ignore
File ".../lib/python3.10/site-packages/nemoguardrails/cli/init.py", line 95, in chat
run_chat(
File ".../lib/python3.10/site-packages/nemoguardrails/cli/chat.py", line 610, in run_chat
asyncio.run(_run_chat_v2_x(rails_app))
File ".../lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File ".../lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File ".../lib/python3.10/site-packages/nemoguardrails/cli/chat.py", line 497, in _run_chat_v2_x
await _process_input_events()
File ".../lib/python3.10/site-packages/nemoguardrails/cli/chat.py", line 439, in _process_input_events
output_events, output_state = await rails_app.process_events_async(
File ".../lib/python3.10/site-packages/nemoguardrails/rails/llm/llmrails.py", line 973, in process_events_async
output_events, output_state = await self.runtime.process_events(
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/runtime/runtime.py", line 436, in process_events
initialize_state(state)
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/runtime/statemachine.py", line 94, in initialize_state
initialize_flow(state, flow_config)
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/runtime/statemachine.py", line 112, in initialize_flow
flow_config.elements = expand_elements(flow_config.elements, state.flow_configs)
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/lang/expansion.py", line 71, in expand_elements
expanded_elements = _expand_await_element(element)
File ".../lib/python3.10/site-packages/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'>'
How can I fix this?
Any help would be greatly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to follow the documentation for calling an asynchronous function as an action.
Here is the relevant code from the docs:
in actions.py
from nemoguardrails.actions import action
@action(name="CustomAsyncTestAction", execute_async=True)
async def custom_test(value: int):
return value + value
in main.co
import core
flow main
start CustomTestAction(value=5) as $action_ref
await $action_ref.Finished() as $event_ref
bot say "The result is: {$event_ref.return_value}" # Access the function return value via the event reference
This isn't working for me. I keep getting the following error:
ColangSyntaxError: Unsupported spec type '<class 'nemoguardrails.colang.v2_x.lang.colang_ast.Spec'>'
This is the traceback:
Traceback (most recent call last):
File ".../bin/nemoguardrails", line 8, in
sys.exit(app())
File ".../lib/python3.10/site-packages/typer/main.py", line 328, in call
raise e
File ".../lib/python3.10/site-packages/typer/main.py", line 311, in call
return get_command(self)(*args, **kwargs)
File ".../lib/python3.10/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File ".../lib/python3.10/site-packages/typer/core.py", line 783, in main
return _main(
File ".../lib/python3.10/site-packages/typer/core.py", line 225, in _main
rv = self.invoke(ctx)
File ".../lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File ".../lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File ".../lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File ".../lib/python3.10/site-packages/typer/main.py", line 683, in wrapper
return callback(**use_params) # type: ignore
File ".../lib/python3.10/site-packages/nemoguardrails/cli/init.py", line 95, in chat
run_chat(
File ".../lib/python3.10/site-packages/nemoguardrails/cli/chat.py", line 610, in run_chat
asyncio.run(_run_chat_v2_x(rails_app))
File ".../lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File ".../lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File ".../lib/python3.10/site-packages/nemoguardrails/cli/chat.py", line 497, in _run_chat_v2_x
await _process_input_events()
File ".../lib/python3.10/site-packages/nemoguardrails/cli/chat.py", line 439, in _process_input_events
output_events, output_state = await rails_app.process_events_async(
File ".../lib/python3.10/site-packages/nemoguardrails/rails/llm/llmrails.py", line 973, in process_events_async
output_events, output_state = await self.runtime.process_events(
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/runtime/runtime.py", line 436, in process_events
initialize_state(state)
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/runtime/statemachine.py", line 94, in initialize_state
initialize_flow(state, flow_config)
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/runtime/statemachine.py", line 112, in initialize_flow
flow_config.elements = expand_elements(flow_config.elements, state.flow_configs)
File ".../lib/python3.10/site-packages/nemoguardrails/colang/v2_x/lang/expansion.py", line 71, in expand_elements
expanded_elements = _expand_await_element(element)
File ".../lib/python3.10/site-packages/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'>'
How can I fix this?
Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions