langsmith-rust 0.1.2

Rust crate for manual tracing to LangSmith, providing similar ergonomics to the Python and TypeScript SDKs
Documentation
use serde_json::Value;

/// Observer trait for observing node execution events
pub trait Observer: Send + Sync {
    /// Called when a node starts execution
    fn on_node_start(&self, node_name: &str, inputs: &Value);
    
    /// Called when a node completes successfully
    fn on_node_end(&self, node_name: &str, outputs: &Value);
    
    /// Called when a node encounters an error
    fn on_node_error(&self, node_name: &str, error: &str);
}

/// LangSmith observer that traces to LangSmith
pub struct LangSmithObserver {
    // Can hold tracer or client
}

impl LangSmithObserver {
    pub fn new() -> Self {
        Self {}
    }
}

impl Observer for LangSmithObserver {
    fn on_node_start(&self, node_name: &str, _inputs: &Value) {
        // Implementation would create a tracer and post the run
        // This is a simplified version - actual implementation would use Tracer
        eprintln!("LangSmithObserver: Node '{}' started", node_name);
    }

    fn on_node_end(&self, node_name: &str, _outputs: &Value) {
        // Implementation would patch the run with outputs
        eprintln!("LangSmithObserver: Node '{}' completed", node_name);
    }

    fn on_node_error(&self, node_name: &str, error: &str) {
        // Implementation would patch the run with error
        eprintln!("LangSmithObserver: Node '{}' error: {}", node_name, error);
    }
}

impl Default for LangSmithObserver {
    fn default() -> Self {
        Self::new()
    }
}