tianshu_observe/lib.rs
1// Copyright 2026 Desicool
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! Observer implementations for the Tianshu workflow engine.
6//!
7//! This crate provides ready-made `Observer` implementations and dataset
8//! export utilities to complement `workflow_engine`'s observer trait.
9//!
10//! # Observers
11//!
12//! | Type | Description |
13//! |------|-------------|
14//! | [`InMemoryObserver`] | Accumulates records in memory. For testing and programmatic access. |
15//! | [`JsonlObserver`] | Appends one JSON line per event to a file. For RLHF dataset building. |
16//! | [`CompositeObserver`] | Fans out events to multiple child observers simultaneously. |
17//!
18//! # Dataset export
19//!
20//! The [`dataset`] module provides functions to extract RLHF-ready
21//! input/output pairs from collected records:
22//!
23//! ```rust,ignore
24//! use tianshu_observe::{InMemoryObserver, dataset::step_dataset};
25//!
26//! let obs = Arc::new(InMemoryObserver::new());
27//! scheduler.set_observer(obs.clone());
28//!
29//! // ... run workflows ...
30//!
31//! // Get only original (non-cached) step executions for fine-tuning
32//! let entries = step_dataset(&obs.step_records());
33//! for entry in &entries {
34//! println!("{} -> {}", entry.input, entry.output);
35//! }
36//! ```
37
38pub mod composite;
39pub mod dataset;
40pub mod jsonl;
41pub mod memory;
42
43pub use composite::CompositeObserver;
44pub use jsonl::JsonlObserver;
45pub use memory::InMemoryObserver;