NVIDIA / NeMo-Guardrails

NeMo Guardrails is an open-source toolkit for easily adding programmable guardrails to LLM-based conversational systems.
Other
3.72k stars 328 forks source link

GerenateFlowFromName created unparsable flow #509

Open rgstephens opened 1 month ago

rgstephens commented 1 month ago

Looks like GenerateFlowFromName is creating a flow with a single quote that trips up parsing.

GenerateFlowFromNameActionFinished
{"action_uid": "396a...", "action_name": "GenerateFlowFromNameAction", "status": "success", "is_success": true, "return_value": "flow bot execute location_api\n  bot access location_api\n  bot retrieve user's location\n  
bot return location data", "events": []}
StartAddFlowsAction
{"action_uid": "f960...", "config": "flow bot execute location_api\n  bot access location_api\n  bot retrieve user's location\n  bot return location data"}
⠦ Working ...WARNING:nemoguardrails.colang.v2_x.runtime.runtime:Failed parsing a generated flow
flow bot execute location_api
  bot access location_api
  bot retrieve user's location
  bot return location data
No terminal matches ''' in the current parser context, at line 3 col 20

  bot retrieve user's location
                   ^
Expected one of: 
        * VAR_NAME
        * LPAR
        * LBRACE
        * PLUS
        * DOT
        * "->"
        * NAME
        * LSQB
        * EQUAL
        * TILDE
        * _OR
        * MINUS
        * FLOAT_NUMBER
        * DEC_NUMBER
        * STRING
        * _AND
        * LONG_STRING
        * RPAR
        * _NEWLINE

Previous tokens: Token('NAME', 'user')

Failed parsing a generated flow
flow bot execute location_api
  bot access location_api
  bot retrieve user's location
  bot return location data
No terminal matches ''' in the current parser context, at line 3 col 20

  bot retrieve user's location
                   ^
Expected one of: 
        * VAR_NAME
        * LPAR
        * LBRACE
        * PLUS
        * DOT
        * "->"
        * NAME
        * LSQB
        * EQUAL
        * TILDE
        * _OR
        * MINUS
        * FLOAT_NUMBER
        * DEC_NUMBER
        * STRING
        * _AND
        * LONG_STRING
        * RPAR
        * _NEWLINE

Previous tokens: Token('NAME', 'user')

Not sure why it's generating a flow:

flow main
  activate llm continuation
  activate greeting
  activate weather
  activate capabilities

flow weather
    user asked about weather
    $coords = execute location_api()
    bot say "I see you are at $coords"
    $weather_report = execute weather_api(coords=$coords)
    bot respond answer weather
rgstephens commented 1 month ago

This was caused by a syntax error (using colang 1.0). The old format:

$weather_info = execute openweather_query(location=$location)

Should now be:

$weather_info = await openweather_query(location=$location)
drazvan commented 1 month ago

Thanks for reporting this @rgstephens! I think we can raise some sort of warning for Colang 1.0 vs 2.0 incompatibilities, which are not raising errors, like this one. We'll follow up on this.