Skip to main content

ai_lib_rust/
lib.rs

1//! # ai-lib-rust
2//!
3//! Protocol Runtime for AI-Protocol - A high-performance Rust reference implementation.
4//!
5//! This library implements the AI-Protocol specification as a runtime, where all logic
6//! is operators and all configuration is protocol. It provides a unified interface
7//! for interacting with AI models across different providers without hardcoding
8//! provider-specific logic.
9
10pub mod client;
11pub mod pipeline;
12pub mod protocol;
13pub mod resilience;
14pub mod telemetry;
15pub mod transport;
16pub mod types;
17pub mod utils;
18
19#[cfg(feature = "routing_mvp")]
20pub mod routing;
21
22#[cfg(feature = "interceptors")]
23pub mod interceptors;
24
25// Re-export main types for convenience
26pub use client::CallStats;
27pub use client::CancelHandle;
28pub use client::ChatBatchRequest;
29pub use client::EndpointExt;
30pub use client::{AiClient, AiClientBuilder};
31pub use telemetry::{FeedbackEvent, FeedbackSink};
32pub use types::{
33    events::StreamingEvent,
34    message::{Message, MessageRole},
35    tool::ToolCall,
36};
37
38// Optional re-exports
39#[cfg(feature = "routing_mvp")]
40pub use routing::{
41    CustomModelManager, LoadBalancingStrategy, ModelArray, ModelCapabilities, ModelEndpoint,
42    ModelInfo, ModelSelectionStrategy, PerformanceMetrics, PricingInfo, QualityTier, SpeedTier,
43};
44
45use futures::Stream;
46use std::pin::Pin;
47
48/// Result type alias for the library
49pub type Result<T> = std::result::Result<T, Error>;
50
51/// A specialized Result for pipeline operations
52pub type PipeResult<T> = std::result::Result<T, Error>;
53
54/// A unified pinned, boxed stream that emits PipeResult<T>
55pub type BoxStream<'a, T> = Pin<Box<dyn Stream<Item = PipeResult<T>> + Send + 'a>>;
56
57/// Error type for the library
58pub mod error;
59pub use error::{Error, ErrorContext};