pub struct MetricContext {
pub stype: String,
pub payload: Value,
pub response: Option<Value>,
pub tool_name: Option<String>,
pub arguments: Option<Value>,
pub assertions: Option<AssertionSet>,
pub toc_result: Option<TocResult>,
pub sources: Vec<Source>,
pub previous_response: Option<Value>,
pub ontology_constraints: Option<OntologyConstraints>,
pub metadata: HashMap<String, Value>,
}Expand description
Context for metric computation
Contains all the data needed to compute QoM metrics for a request/response.
Fields§
§stype: StringThe SType being validated
payload: ValueThe request payload
response: Option<Value>The response payload (for TOC)
tool_name: Option<String>Tool name (if this is a tool call)
arguments: Option<Value>Request arguments
assertions: Option<AssertionSet>Assertions to evaluate for IC
toc_result: Option<TocResult>TOC verification result from external source (header or callback)
sources: Vec<Source>Sources/citations for groundedness checking
previous_response: Option<Value>Previous response for determinism comparison
ontology_constraints: Option<OntologyConstraints>Ontology constraints
metadata: HashMap<String, Value>Additional metadata
Implementations§
Source§impl MetricContext
impl MetricContext
Sourcepub fn new(stype: impl Into<String>, payload: Value) -> Self
pub fn new(stype: impl Into<String>, payload: Value) -> Self
Create a new context for a payload
Sourcepub fn with_response(self, response: Value) -> Self
pub fn with_response(self, response: Value) -> Self
Add response data
Sourcepub fn with_assertions(self, assertions: AssertionSet) -> Self
pub fn with_assertions(self, assertions: AssertionSet) -> Self
Add assertions for IC computation
Sourcepub fn with_toc_result(self, result: TocResult) -> Self
pub fn with_toc_result(self, result: TocResult) -> Self
Add TOC result from external verification
Sourcepub fn with_sources(self, sources: Vec<Source>) -> Self
pub fn with_sources(self, sources: Vec<Source>) -> Self
Add sources for groundedness checking
Sourcepub fn with_previous_response(self, previous: Value) -> Self
pub fn with_previous_response(self, previous: Value) -> Self
Add previous response for determinism checking
Sourcepub fn with_ontology(self, constraints: OntologyConstraints) -> Self
pub fn with_ontology(self, constraints: OntologyConstraints) -> Self
Add ontology constraints
Sourcepub fn to_evaluation_context(&self) -> EvaluationContext
pub fn to_evaluation_context(&self) -> EvaluationContext
Convert to assertion evaluation context
Trait Implementations§
Source§impl Clone for MetricContext
impl Clone for MetricContext
Source§fn clone(&self) -> MetricContext
fn clone(&self) -> MetricContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MetricContext
impl Debug for MetricContext
Source§impl Default for MetricContext
impl Default for MetricContext
Source§fn default() -> MetricContext
fn default() -> MetricContext
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MetricContext
impl<'de> Deserialize<'de> for MetricContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MetricContext
impl RefUnwindSafe for MetricContext
impl Send for MetricContext
impl Sync for MetricContext
impl Unpin for MetricContext
impl UnwindSafe for MetricContext
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
Attempts to downcast this to
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
Attempts to downcast this to
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
Attempts to downcast this to
T behind Arc pointerSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more