Class BowireMetricExpression
- Namespace
- Kuestenlogik.Bowire.Benchmarking
- Assembly
- Kuestenlogik.Bowire.Benchmarking.dll
#621 — an arithmetic expression over the values a response reports:
usage.prompt_tokens * rate.input + usage.completion_tokens * rate.output.
Numbers, + - * / and parentheses combine references. A reference
is a path into the JSON body (usage.prompt_tokens,
choices[0].usage.total, data[id=gpt-x].pricing.prompt,
["x-key"] for a key that is not a plain name), header.name
(or header["x-retry-count"]) for a response header, or
rate.name for a rate of the run's price profile. body.
names the body explicitly where a key is called header or rate.
A reference yields a number, a string holding a number, or a boolean (1 / 0); anything else, or a reference that is not there, makes the value missing.
public sealed class BowireMetricExpression
- Inheritance
-
BowireMetricExpression
- Inherited Members
Properties
Rates
The rate names the expression uses, which the run's price profile must have.
public IReadOnlySet<string> Rates { get; }
Property Value
Source
The expression as written.
public string Source { get; }
Property Value
Methods
Evaluate(BowireMetricContext, out string?)
The value for one response, or null with the missing
reason (the first reference that is not there or not a number, a division by zero).
public double? Evaluate(BowireMetricContext context, out string? missing)
Parameters
contextBowireMetricContextmissingstring
Returns
TryParse(string?, out BowireMetricExpression?, out string?)
Parse an expression; false with a readable error when it does not parse.
public static bool TryParse(string? text, out BowireMetricExpression? expression, out string? error)
Parameters
textstringexpressionBowireMetricExpressionerrorstring
Returns
TryResolve(JsonElement, string, out double, out string?)
Resolve a body path (the reference syntax, without header. /
rate.) against root — used to read a provider's
served rates with the same paths an expression uses.
public static bool TryResolve(JsonElement root, string path, out double value, out string? reason)
Parameters
rootJsonElementpathstringvaluedoublereasonstring