`generate_events` fails with colang 2.0
Calling generate_events for a colang 2.0 config aborts
Traceback (most recent call last):
File "/Users/greg/Dev/nemo/NeMo-Guardrails-rgstephens/generate_events.py", line 19, in <module>
new_events = app.generate_events(
File "/Users/greg/Dev/nemo/NeMo-Guardrails-rgstephens/nemoguardrails/rails/llm/llmrails.py", line 947, in generate_events
return loop.run_until_complete(self.generate_events_async(events=events))
File "/Users/greg/.pyenv/versions/3.10.13/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/Users/greg/Dev/nemo/NeMo-Guardrails-rgstephens/nemoguardrails/rails/llm/llmrails.py", line 919, in generate_events_async
new_events = await self.runtime.generate_events(
TypeError: RuntimeV2_x.generate_events() got an unexpected keyword argument 'processing_log'
+1
+1
Thanks for reporting this!
You should use process_events for Colang 2.0 configs. But we'll fix the generate_events as well.
Hi @drazvan, thank you for that. Is there a full events-api example for colang 2.0? I was able to use the process_events with a clean new state, but can't get it work with an existing state.
What exactly is the issue with an existing state? Can you share a small snippet to reproduce?
The serialization test here: https://github.com/NVIDIA/NeMo-Guardrails/blob/develop/tests/v2_x/test_state_serialization.py#L142 uses process_events with an existing state.
Getting the following error when trying to parse state to json and back:
__init__() missing 1 required positional argument: '_type'
I'm saving the state and events to a db so it goes through serialization.
Basically something like that:
rails = LLMRails(config=config, verbose=True)
input_events = [
{
"type": "UtteranceUserActionFinished",
"final_transcript": "hi",
}
]
output_events, state = await rails.runtime.process_events(
events=input_events, state={}, blocking=True
)
state = state_to_json
# serialize and save to db
s = get_state_from_db_and_deserialize()
state = json_to_state(s)
+1