mod variable_extractor#

module variable_extractor#

Variable content detection and extraction from prompt blocks.

Functions

fn default_variable_patterns() -> Vec<VariablePattern>#

Return the default regex patterns used for variable extraction.

Returns

A vector of built-in VariablePattern values covering common timestamps and request identifiers.

fn extract_variables(content: &str, span_id: &SpanId, patterns: &[VariablePattern]) -> Option<ExtractionResult>#

Extract variables from one content string.

Matching patterns are applied greedily by start position, preferring longer matches when multiple patterns overlap.

Parameters

  • content: Block content to analyze.

  • span_id: Span identifier associated with the content.

  • patterns: Variable patterns to evaluate.

Returns

Some(ExtractionResult) when at least one variable is found and None otherwise.

fn extract_variables_from_blocks(blocks: &[PromptBlock], patterns: &[VariablePattern]) -> Vec<ExtractionResult>#

Extract variables from a set of prompt blocks.

Parameters

  • blocks: Prompt blocks to analyze.

  • patterns: Variable patterns to evaluate.

Returns

One ExtractionResult per block that contained at least one variable.

Enums

enum VariableCategory#

Category assigned to an extracted variable.

Timestamp#

Timestamp-like content such as ISO 8601 strings.

RequestId#

Request or trace identifier content.

SessionId#

Session identifier content.

Locale#

Locale identifier content.

Custom(String)#

Caller-defined variable category.

Structs and Unions

struct ExtractedVariable#

One extracted variable occurrence within a prompt block.

pattern_name: String#

Name of the pattern that matched this value.

original_value: String#

Original matched value before replacement.

byte_offset: usize#

Byte offset of the match in the original content.

byte_length: usize#

Byte length of the original match.

category: VariableCategory#

Semantic category assigned to the variable.

struct ExtractionResult#

Variable extraction result for one prompt block.

span_id: SpanId#

Span identifier of the analyzed block.

template_content: String#

Block content with extracted values replaced by placeholders.

variables: Vec<ExtractedVariable>#

Variables extracted from the block.

struct VariablePattern#

Regex-based pattern used to detect variable content.

name: String#

Stable placeholder name inserted into the template.

regex: Regex#

Regex used to detect matching content.

category: VariableCategory#

Semantic category assigned to matches from this pattern.

Traits implemented

impl std::fmt::Debug for VariablePattern#