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 batch;
11pub mod cache;
12pub mod client;
13pub mod embeddings;
14pub mod pipeline;
15pub mod plugins;
16pub mod protocol;
17pub mod resilience;
18pub mod telemetry;
19pub mod tokens;
20pub mod transport;
21pub mod types;
22pub mod utils;
23
24#[cfg(feature = "routing_mvp")]
25pub mod routing;
26
27#[cfg(feature = "interceptors")]
28pub mod interceptors;
29
30// Re-export main types for convenience
31pub use client::CallStats;
32pub use client::CancelHandle;
33pub use client::ChatBatchRequest;
34pub use client::EndpointExt;
35pub use client::{AiClient, AiClientBuilder};
36pub use telemetry::{FeedbackEvent, FeedbackSink};
37pub use types::{
38    events::StreamingEvent,
39    message::{Message, MessageRole},
40    tool::ToolCall,
41};
42
43// Optional re-exports
44#[cfg(feature = "routing_mvp")]
45pub use routing::{
46    CustomModelManager, LoadBalancingStrategy, ModelArray, ModelCapabilities, ModelEndpoint,
47    ModelInfo, ModelSelectionStrategy, PerformanceMetrics, PricingInfo, QualityTier, SpeedTier,
48};
49
50use futures::Stream;
51use std::pin::Pin;
52
53/// Result type alias for the library
54pub type Result<T> = std::result::Result<T, Error>;
55
56/// A specialized Result for pipeline operations
57pub type PipeResult<T> = std::result::Result<T, Error>;
58
59/// A unified pinned, boxed stream that emits PipeResult<T>
60pub type BoxStream<'a, T> = Pin<Box<dyn Stream<Item = PipeResult<T>> + Send + 'a>>;
61
62/// Error type for the library
63pub mod error;
64pub use error::{Error, ErrorContext};