> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.colang

## Subpackages

* **[`nemoguardrails.colang.v1_0`](/guardrails-python-sdk/nemoguardrails/colang/v1_0)**
* **[`nemoguardrails.colang.v2_x`](/guardrails-python-sdk/nemoguardrails/colang/v2_x)**

## Submodules

* **[`nemoguardrails.colang.runtime`](/guardrails-python-sdk/nemoguardrails/colang/runtime)**

## Package Contents

### Functions

| Name                                                                | Description                                              |
| ------------------------------------------------------------------- | -------------------------------------------------------- |
| [`_is_colang_v2`](#nemoguardrails-colang-_is_colang_v2)             | Checks if the content of a file is in Colang 2.x format. |
| [`parse_colang_file`](#nemoguardrails-colang-parse_colang_file)     | Parse the content of a .co file into the CoYML format.   |
| [`parse_flow_elements`](#nemoguardrails-colang-parse_flow_elements) | Parse the flow elements from CoYML format to CIL.        |

### Data

[`log`](#nemoguardrails-colang-log)

### API

```python
nemoguardrails.colang._is_colang_v2(
    content
)
```

Checks if the content of a file is in Colang 2.x format.

This function uses a simple heuristic to determine if the content is a Colang 2.x file.
Initially, it removes comments and content within triple quotes, as these could potentially
contain misleading keywords. Then, it checks for the presence of certain keywords in the content:

* If the keyword `import` is present, the content is likely a Colang 2.x file.
* If the keyword `define` is present at the beginning of a line, the content is likely a Colang 1.0 file.

**Parameters:**

The content of the file to check.

**Returns:**

True if the content is likely a Colang 2.x file, False otherwise.

```python
nemoguardrails.colang.parse_colang_file(
    filename: str,
    content: str,
    include_source_mapping: bool = True,
    version: str = '1.0'
)
```

Parse the content of a .co file into the CoYML format.

```python
nemoguardrails.colang.parse_flow_elements(
    items,
    version: str = '1.0'
)
```

Parse the flow elements from CoYML format to CIL.

```python
nemoguardrails.colang.log = logging.getLogger(__name__)
```