Module simulator

Module simulator 

Source
Expand description

Workflow execution simulator for dry-run testing

This module provides simulation capabilities for workflows, allowing users to:

  • Test workflows without making real API calls
  • Validate all execution paths including error handling
  • Estimate costs and execution times
  • Generate execution traces for debugging
  • Test conditional branches and loops

§Example

use oxify_model::*;
use std::collections::HashMap;

let config = LlmConfig {
    provider: "openai".to_string(),
    model: "gpt-4".to_string(),
    system_prompt: None,
    prompt_template: "Generate: {{input}}".to_string(),
    temperature: Some(0.7),
    max_tokens: None,
    tools: vec![],
    images: vec![],
    extra_params: serde_json::Value::Null,
};

let workflow = WorkflowBuilder::new("Test")
    .start("start")
    .llm("gen", config)
    .end("end")
    .build();

let mut context = HashMap::new();
context.insert("input".to_string(), serde_json::json!("hello"));

let result = WorkflowSimulator::new()
    .with_mock_responses(vec![
        ("gen".to_string(), serde_json::json!("mock response"))
    ])
    .simulate(&workflow, context);

assert!(result.is_ok());

Structs§

CoverageInfo
Branch coverage information
ExecutionTrace
Execution trace showing the path taken through the workflow
NodeExecutionDetail
Details of a single node execution in simulation
SimulationError
Simulation error
SimulationResult
Result of a workflow simulation
WorkflowSimulator
Workflow simulator for dry-run executions