> 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.kb.utils

## Module Contents

### Functions

| Name                                                                                        | Description                                  |
| ------------------------------------------------------------------------------------------- | -------------------------------------------- |
| [`split_markdown_in_topic_chunks`](#nemoguardrails-kb-utils-split_markdown_in_topic_chunks) | Splits a markdown content into topic chunks. |

### API

```python
nemoguardrails.kb.utils.split_markdown_in_topic_chunks(
    content: str,
    max_chunk_size: int = 400
) -> typing.List[dict]
```

Splits a markdown content into topic chunks.

This function takes a markdown content as input and divides it into topic chunks based on
headings and subsections. Each chunk includes a title and body, with an optional maximum size.

Parameters:

* content (str): The markdown content to be split.
* max\_chunk\_size (int): The maximum size of a chunk. Default is 400.

Returns:
List\[dict]: A list of dictionaries, each representing a topic chunk with 'title' and 'body' keys.

Example:

```python
content = "# Introduction

This is an introduction.
## Section 1

Content of section 1."
chunks = split_markdown_in_topic_chunks(content, max_chunk_size=500)
```

Note:

* The function considers '#' as heading markers.
* Meta information can be included at the beginning of the markdown using triple backticks.