Expand description
Inference key parsing for Agentic Inference Markup (AIM) format.
This module provides functionality for parsing inference keys, which are UPPERCASE C-style identifiers used in AIM files to identify different types of inference directives and their termination patterns. These keys are used to structure inference prompts and parse model responses.
§Key Grammar
The key grammar supports three different suffix patterns:
key_colon_eol: UCID ‘:’ whitespace? end-of-line (e.g.,INSTRUCTIONS:\\n) - indicates multi-line content followskey_eol: UCID whitespace? end-of-line (e.g.,SYSTEM\\n) - indicates simple value on same linekey_colon: UCID ‘:’ (e.g.,MODEL:) - indicates inline value follows
§Examples
In AIM files, inference keys are used to structure prompts:
// Modifier rules in AIM files
SYSTEM: You are a helpful assistant
INSTRUCTIONS:
Summarize the following text in 100 words or less.
Focus on key points and maintain clarity.
MODEL: gpt-4In model responses, keys indicate how to parse the returned content:
ANSWER: 42
LIST:
- First item
- Second item
SUMMARY
This is a summary on the same line.The parser recognizes these keys and their different termination patterns to properly structure inference prompts and parse responses.
Enums§
- Suffix
- Represents the different suffix patterns that can follow an inference key.
Functions§
- parse_
key - Parse an inference key according to the AIM grammar.
- parse_
ucid - Parse an UPPERCASE C-style identifier (UCID).