NeMo-Guardrails icon indicating copy to clipboard operation
NeMo-Guardrails copied to clipboard

`generate_events` fails with colang 2.0

Open rgstephens opened this issue 1 year ago • 7 comments

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'

rgstephens avatar May 17 '24 17:05 rgstephens

+1

baravit avatar May 19 '24 09:05 baravit

+1

d-shree avatar May 20 '24 07:05 d-shree

Thanks for reporting this! You should use process_events for Colang 2.0 configs. But we'll fix the generate_events as well.

drazvan avatar May 20 '24 21:05 drazvan

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.

baravit avatar May 22 '24 13:05 baravit

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.

drazvan avatar May 22 '24 20:05 drazvan

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)

baravit avatar May 27 '24 13:05 baravit

+1

aitamar avatar Jun 02 '24 13:06 aitamar