NVIDIA / NeMo-Guardrails

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

Creating the config and colang files from python code itself #22

Closed cvarun94 closed 1 year ago

cvarun94 commented 1 year ago

Hi,

Thank you for the opensource tool. I want to create the config files (instruction, sample conversation) and the colang files (having canonical definition and flow definition) programmatically from python code itself. My aim is to take these as inputs using python and generate the config and colang files. Is this possible using nemoguardrails python-api and how to do this?

baravit commented 1 year ago

+1

drazvan commented 1 year ago

Hi @cvarun94!

You can use the RailsConfig.from_content(colang_content, yaml_content) method (https://github.com/NVIDIA/NeMo-Guardrails/blob/main/nemoguardrails/rails/llm/config.py#L204). You can see examples in some of the tests e.g. https://github.com/NVIDIA/NeMo-Guardrails/blob/main/tests/test_flow_when.py#L19.

You can generate the colang_content and yaml_content dynamically from your python code. Is this what you meant or was it something else?