adm_ai_rag_chunk_api
Chunking API for RAG implementations Provides reusable text chunking functionality with smart break points and support for markdown headers
Default chunking parameters:
- Target chunk size: 2048 characters (approximately 512 tokens)
- Minimum chunk size: 512 characters (25% of target)
- Maximum chunk size: 2560 characters (150% of target)
- Overlap size: 256 characters (12.5% of target)
Functions and Procedures
Section titled “Functions and Procedures”find_break_point
Section titled “find_break_point”Find the next good break point in content Prefers: paragraph breaks, code blocks, sentence endings, then newlines
Signature:
function find_break_point ( p_content in clob, p_start_pos in number, p_target_pos in number, p_max_pos in number) return number;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_content | in | clob | The content to search in |
p_start_pos | in | number | The starting position for the search |
p_target_pos | in | number | The target position for the break |
p_max_pos | in | number | The maximum position allowed |
Returns: number - Position where the break should occur
find_header_positions
Section titled “find_header_positions”Find header positions in markdown content Returns table of positions where headers start
Signature:
function find_header_positions ( p_content in clob) return sys.odcinumberlist;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_content | in | clob | The markdown content to analyze |
Returns: sys.odcinumberlist - Collection of header positions
find_html_heading_positions
Section titled “find_html_heading_positions”Find HTML heading positions (h1-h6 tags) Returns table of positions where headings start
Signature:
function find_html_heading_positions ( p_content in clob) return sys.odcinumberlist;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_content | in | clob | The HTML content to analyze |
Returns: sys.odcinumberlist - Collection of heading positions
find_html_tag_positions
Section titled “find_html_tag_positions”Find HTML tag boundaries (major structural tags like div, section, article, table) Returns table of positions where these tags start
Signature:
function find_html_tag_positions ( p_content in clob) return sys.odcinumberlist;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_content | in | clob | The HTML content to analyze |
Returns: sys.odcinumberlist - Collection of tag positions
find_json_structure_positions
Section titled “find_json_structure_positions”Find JSON object/array boundaries at root level Returns table of positions where top-level structures start
Signature:
function find_json_structure_positions ( p_content in clob) return sys.odcinumberlist;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_content | in | clob | The JSON content to analyze |
Returns: sys.odcinumberlist - Collection of boundary positions
find_xml_element_positions
Section titled “find_xml_element_positions”Find XML element boundaries (major elements) Returns table of positions where major elements start
Signature:
function find_xml_element_positions ( p_content in clob) return sys.odcinumberlist;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_content | in | clob | The XML content to analyze |
Returns: sys.odcinumberlist - Collection of element positions
find_paragraph_positions
Section titled “find_paragraph_positions”Find paragraph boundaries in plain text content Returns table of positions where paragraphs start
Signature:
function find_paragraph_positions ( p_content in clob) return sys.odcinumberlist;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_content | in | clob | The text content to analyze |
Returns: sys.odcinumberlist - Collection of paragraph positions
get_chunking_strategy
Section titled “get_chunking_strategy”Determine chunking strategy based on MIME type Returns: ‘markdown_headers’, ‘html_tags’, ‘json_structure’, ‘xml_elements’, ‘paragraphs’, or ‘default’
Signature:
function get_chunking_strategy ( p_mime_type in varchar2) return varchar2;Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_mime_type | in | varchar2 | The MIME type of the content |
Returns: varchar2 - The chunking strategy to use
create_rag_chunks
Section titled “create_rag_chunks”Create RAG chunks for content with MIME type-aware chunking strategy Automatically selects appropriate chunking strategy based on content type:
- Markdown: respects headers (h1-h6)
- HTML: respects major structural tags (div, section, article, table)
- JSON: respects root-level objects/arrays
- XML: respects major element boundaries
- Plain text: respects paragraph boundaries
- Other: uses character-based smart breaking
Signature:
procedure create_rag_chunks ( p_file_id in adm_ai_rag_collection_files.rag_collection_file_id%type, p_target_chunk_size in number default 2048, p_min_chunk_size in number default 512, p_max_chunk_size in number default 2560, p_overlap_size in number default 256);Parameters:
| Name | Direction | Type | Description |
|---|---|---|---|
p_file_id | in | adm_ai_rag_collection_files.rag_collection_file_id%type | The RAG collection file ID |
p_target_chunk_size | in | number default 2048 | Target chunk size in characters (default: 2048) |
p_min_chunk_size | in | number default 512 | Minimum chunk size in characters (default: 512) |
p_max_chunk_size | in | number default 2560 | Maximum chunk size in characters (default: 2560) |
p_overlap_size | in | number default 256 | Overlap size in characters for adjacent chunks (default: 256) |