Skip to content

BMEL Function ReferenceΒΆ

BMEL (BizMetry Expression Language) version 1.1.0 Β· 110 functions across 9 categories. Use the table below to navigate directly to any function, or browse by category in the left sidebar.


πŸ€– LLM & AI ObservabilityΒΆ

Function Returns Description
bmel:LLMInferenceBias number Measures semantic bias between a prompt and an LLM response by computing their cosine similarity ...
bmel:chunkCount integer Returns the number of chunks that a text would be split into given a fixed chunk size in tokens.
bmel:compressionRatio number Returns the token compression ratio between an original text and a compressed/summarized version:...
bmel:containsAny boolean Returns true if the text contains at least one string from the provided array.
bmel:estimateCost number Returns the estimated cost in USD for a given number of tokens and a named model.
bmel:jaccardSimilarity number Returns the Jaccard similarity between two strings, computed as
bmel:levenshteinDistance integer Returns the Levenshtein edit distance between two strings: the minimum number of single-character...
bmel:matchesPattern boolean Returns true if the text matches the given regular expression pattern.
bmel:percentileLatency number Returns the p-th percentile latency from an array of latency measurements (in milliseconds).
bmel:promptToxicityScore number Computes a toxicity score for the given prompt text in the range [0.
bmel:sentenceCount integer Returns the number of sentences in a string, detected by terminal punctuation (.
bmel:sigmoid number Applies the sigmoid activation function to a scalar: 1 / (1 + exp(-x)).
bmel:slaBreached boolean Returns true if the actual value exceeds the defined limit.
bmel:softmax bmel:array<number> Applies the softmax function to an array of numeric logits, returning a probability distribution ...
bmel:threshold boolean Returns true if the value falls within the inclusive range [min, max].
bmel:tokenCount integer Calculates the number of tokens required to represent the given content using the specified token...
bmel:truncateToTokens string Truncates a string to at most maxTokens tokens using the specified tokenizer, cutting at a word b...
bmel:wordCount integer Returns the number of whitespace-delimited words in a string.

πŸ”¬ AI UtilitiesΒΆ

Function Returns Description
bmel:sizeof integer Calculates the byte size of the serialized representation of the given content.

πŸ”€ StringΒΆ

Function Returns Description
bmel:concat string Concatenates two or more values into a single string.
bmel:contains boolean Returns true if the expression contains the specified substring.
bmel:length integer Returns the number of characters in a string, or the number of elements in an array.
bmel:lower string Converts all characters of the string to lowercase.
bmel:replace string Replaces all occurrences of a substring within the expression with a new value.
bmel:substring string Extracts characters from a string between start index (inclusive) and end index (exclusive).
bmel:trim string Removes leading and trailing whitespace from a string.
bmel:upper string Converts all characters of the string to uppercase.

πŸ”’ MathΒΆ

Function Returns Description
bmel:abs number Returns the absolute value of a number.
bmel:avgInlineOf number Returns the arithmetic mean of two or more inline numeric arguments.
bmel:ceil integer Rounds a number up to the nearest integer.
bmel:clamp number Constrains a value to be within the inclusive range [min, max].
bmel:floor integer Rounds a number down to the nearest integer.
bmel:maxInlineOf number Returns the maximum value from two or more inline numeric arguments.
bmel:minInlineOf number Returns the minimum value from two or more inline numeric arguments.
bmel:mod number Returns the remainder of dividing a by b.
bmel:normalize number Applies min-max normalization to a scalar value, rescaling it to the [0, 1] range: (value - min) ...
bmel:pow number Raises a base number to the power of an exponent.
bmel:round number Rounds a number to a specified number of decimal places.
bmel:sign integer Returns -1 if the number is negative, 0 if zero, or 1 if positive.
bmel:sqrt number Returns the square root of a number.
bmel:stddevInlineOf number Returns the population standard deviation of two or more inline numeric arguments.
bmel:zScore number Returns the z-score (standard score) of a value: (value - mean) / stddev.

πŸ“Š Array & StatisticsΒΆ

Function Returns Description
bmel:avg number Returns the arithmetic mean of all numeric values in an array.
bmel:count integer Returns the number of elements in an array.
bmel:countIf integer Returns the count of elements in an array that satisfy the given boolean condition.
bmel:cvOf number Returns the coefficient of variation (CV = stddev / mean) of an array, expressed as a ratio.
bmel:distinct array Returns a new array with all duplicate values removed.
bmel:first any Returns the first element of an array.
bmel:flatten array Flattens one level of nested arrays into a single flat array.
bmel:iqrOf number Returns the interquartile range (IQR = Q3 - Q1) of an array.
bmel:last any Returns the last element of an array.
bmel:maxOf number Returns the maximum numeric value in an array.
bmel:medianOf number Returns the median (50th percentile) of all numeric values in an array.
bmel:minOf number Returns the minimum numeric value in an array.
bmel:modeOf any Returns the most frequently occurring value in an array.
bmel:outlierCountOf integer Returns the number of elements in an array that deviate from the mean by more than (threshold x s...
bmel:percentileOf number Returns the p-th percentile of all numeric values in an array using linear interpolation (equival...
bmel:rangeOf number Returns the statistical range of an array (max - min).
bmel:stddevOf number Returns the population standard deviation of all numeric values in an array column.
bmel:sum number Returns the sum of all numeric values in an array.
bmel:sumIf number Returns the sum of numeric values in an array that satisfy the given boolean condition.
bmel:varianceOf number Returns the population variance of all numeric values in an array.

βš™οΈ Logic & Control FlowΒΆ

Function Returns Description
bmel:coalesce any Returns the first non-null / non-empty value from the provided arguments, evaluated left to right.
bmel:forRange array Iterates from bmel:from to bmel:to (both inclusive, step +1) and evaluates bmel:body at each step...
bmel:if any Inline conditional (ternary): returns a if cond is true, otherwise returns b.
bmel:not boolean Returns the boolean negation of the expression.
bmel:nvl any Returns the expression value, or the fallback value if the expression is null or empty.
bmel:self any Identity function.
bmel:switch any Evaluates bmel:subject against one or more case/result pairs (left to right) and returns the resu...
bmel:toEnumValue enum Converts a bmel:string to its matching bmel:enum constant by exact case-sensitive match.

πŸ“¦ JSONΒΆ

Function Returns Description
bmel:json-depth integer Returns the maximum nesting depth of a JSON object or array.
bmel:json-flatten string Serializes a nested JSON object into a compact, single-level JSON string using dot-notation keys.
bmel:json-keys array Returns an array of the top-level key names of a JSON object.
bmel:json-merge string Performs a shallow merge of two JSON objects and returns the result as a JSON string.
bmel:json-omit string Returns a new JSON string with the specified top-level keys removed.
bmel:json-path any Extracts a value from a JSON string or object using a JSONPath expression.
bmel:json-pick string Returns a new JSON string containing only the specified top-level keys from the input object.
bmel:json-valid boolean Returns true if the input string is valid, parseable JSON; false otherwise.

πŸ“… Date & TimeΒΆ

Function Returns Description
bmel:addDays bmel:date | bmel:datetime Adds N days to a date or datetime value.
bmel:addHours datetime Adds N hours to a datetime value.
bmel:addMonths bmel:date | bmel:datetime Adds N months to a date or datetime value.
bmel:addYears bmel:date | bmel:datetime Adds N years to a date or datetime value.
bmel:dateOf date Extracts the date part from a datetime value, discarding the time component.
bmel:day integer Extracts the day of the month (1-31) from a date or datetime value.
bmel:dayOfWeek integer Returns the day of the week as an integer (1=Monday, 7=Sunday).
bmel:dayOfYear integer Returns the day of the year (1-366) from a date or datetime value.
bmel:diffDays integer Returns the number of days between two dates (a - b).
bmel:diffMonths integer Returns the number of complete months between two dates (a - b).
bmel:endOfDay datetime Returns the datetime at 23:59:59.
bmel:endOfMonth datetime Returns the datetime at 23:59:59.
bmel:formatDate string Formats a date or datetime value into a string using the specified pattern.
bmel:fromEpoch datetime Converts Unix epoch milliseconds to a datetime value.
bmel:hour integer Extracts the hour (0-23) from a datetime value.
bmel:isAfter boolean Returns true if date/datetime a is strictly after b.
bmel:isBefore boolean Returns true if date/datetime a is strictly before b.
bmel:minute integer Extracts the minute (0-59) from a datetime value.
bmel:month integer Extracts the month number (1-12) from a date or datetime value.
bmel:now datetime Returns the current date and time with timezone information.
bmel:parseDate date Parses a string into a date value using the specified format pattern.
bmel:second integer Extracts the second (0-59) from a datetime value.
bmel:startOfDay datetime Returns the datetime at 00:00:00.
bmel:startOfMonth datetime Returns the datetime at 00:00:00.
bmel:timeOf time Extracts the time part from a datetime value, discarding the date component.
bmel:toEpoch number Converts a date or datetime to Unix epoch milliseconds.
bmel:today date Returns the current date at midnight (no time component).
bmel:weekOfYear integer Returns the ISO week number (1-53) from a date or datetime value.
bmel:year integer Extracts the year from a date or datetime value.

πŸ”„ Type ConversionΒΆ

Function Returns Description
bmel:toBoolean boolean Converts the expression to a boolean value.
bmel:toNumber number Converts the expression to a numeric value.
bmel:toString string Converts the expression to its string representation.