pub struct DecisionConfig<T = NoAnswers> {
pub state: Value,
pub model: DecisionModel,
pub questions: BTreeMap<String, DecisionQuestion>,
pub escalate_below: Option<f64>,
/* private fields */
}Expand description
Configuration for a decision step.
T is the struct the answers are read into. new
starts without questions; answers sets them
from T.
§Examples
use ironflow_engine::config::DecisionConfig;
use ironflow_engine::decision::{DecisionAnswers, DecisionChoice};
#[derive(DecisionChoice)]
enum Team {
Billing,
Technical,
}
#[derive(DecisionAnswers)]
struct Triage {
#[noul("Does this convey urgency?")]
is_urgent: f64,
#[choice("Which team?")]
team: Team,
}
let config = DecisionConfig::new("Payouts have been failing for 3 days")
.answers::<Triage>()
.escalate_below(0.7);
assert_eq!(config.questions.len(), 2);
assert_eq!(config.escalate_below, Some(0.7));Fields§
§state: ValueThe state (content) to evaluate.
model: DecisionModelModel route (defaults to DEFAULT_DECISION_MODEL).
questions: BTreeMap<String, DecisionQuestion>Typed questions keyed by name.
escalate_below: Option<f64>Escalate to a human approval gate when any answer’s confidence falls
below this threshold. None never escalates.
Implementations§
Source§impl DecisionConfig
impl DecisionConfig
Sourcepub fn new(state: impl Serialize) -> Self
pub fn new(state: impl Serialize) -> Self
Create a config for the given state (any serializable value).
§Examples
use ironflow_engine::config::DecisionConfig;
use serde_json::json;
let config = DecisionConfig::new(json!({ "ticket": "outage", "priority": 1 }));
assert_eq!(config.model, "jev-latest");
assert!(config.questions.is_empty());Sourcepub fn answers<T: DecisionAnswers>(self) -> DecisionConfig<T>
pub fn answers<T: DecisionAnswers>(self) -> DecisionConfig<T>
Ask the questions declared by T and read the answers into a T.
§Examples
use ironflow_engine::config::DecisionConfig;
use ironflow_engine::decision::DecisionAnswers;
#[derive(DecisionAnswers)]
struct Urgency {
#[noul("Is this urgent?")]
urgent: f64,
}
let config = DecisionConfig::new("x").answers::<Urgency>();
assert!(config.questions.contains_key("urgent"));Source§impl<T> DecisionConfig<T>
impl<T> DecisionConfig<T>
Sourcepub fn model(self, model: impl Into<DecisionModel>) -> Self
pub fn model(self, model: impl Into<DecisionModel>) -> Self
Override the model route.
§Examples
use ironflow_engine::config::DecisionConfig;
let config = DecisionConfig::new("x").model("jev-2");
assert_eq!(config.model, "jev-2");Sourcepub fn escalate_below(self, threshold: f64) -> Self
pub fn escalate_below(self, threshold: f64) -> Self
Set the confidence threshold below which the run escalates to a human.
§Examples
use ironflow_engine::config::DecisionConfig;
let config = DecisionConfig::new("x").escalate_below(0.8);
assert_eq!(config.escalate_below, Some(0.8));Sourcepub fn to_request(&self) -> DecisionRequest
pub fn to_request(&self) -> DecisionRequest
Build the DecisionRequest sent to the provider.
§Examples
use ironflow_engine::config::DecisionConfig;
let request = DecisionConfig::new("hello").to_request();
assert_eq!(request.state, serde_json::json!("hello"));Trait Implementations§
Source§impl<T> Clone for DecisionConfig<T>
impl<T> Clone for DecisionConfig<T>
Source§impl<T> Debug for DecisionConfig<T>
impl<T> Debug for DecisionConfig<T>
Source§impl<'de, T> Deserialize<'de> for DecisionConfig<T>
impl<'de, T> Deserialize<'de> for DecisionConfig<T>
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<T> Freeze for DecisionConfig<T>
impl<T> RefUnwindSafe for DecisionConfig<T>
impl<T> Send for DecisionConfig<T>
impl<T> Sync for DecisionConfig<T>
impl<T> Unpin for DecisionConfig<T>
impl<T> UnsafeUnpin for DecisionConfig<T>
impl<T> UnwindSafe for DecisionConfig<T>
Blanket Implementations§
Source§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