1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![cfg_attr(
3 test,
4 allow(
5 clippy::expect_used,
6 clippy::indexing_slicing,
7 clippy::panic,
8 clippy::unwrap_used,
9 clippy::unreachable
10 )
11)]
12extern crate self as rig;
31
32#[cfg(feature = "audio")]
33#[cfg_attr(docsrs, doc(cfg(feature = "audio")))]
34pub mod audio_generation;
35pub mod catalog;
36pub mod client;
37pub mod completion;
38pub mod conversation;
39pub mod driver;
40pub mod effect;
41pub mod embeddings;
42pub mod error;
43pub use rig_http::http_client;
44pub mod id;
45#[cfg(feature = "image")]
46#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
47pub mod image_generation;
48#[doc(hidden)]
51pub mod json_utils;
52pub mod loaders;
53pub mod markers;
54pub mod model;
55pub mod observe;
56pub mod operation;
57pub mod prelude;
58pub(crate) mod provider_response;
59pub mod providers;
60pub mod redact;
61pub mod rerank;
62pub mod serve;
63
64pub mod streaming;
65pub mod structured_output;
66#[cfg(any(test, feature = "test-utils"))]
67#[cfg_attr(docsrs, doc(cfg(feature = "test-utils")))]
68pub mod test_utils;
69pub mod tool;
70pub mod transcription;
71pub mod vector_store;
72pub use rig_http::wasm_compat;
73pub mod wire;
74#[cfg(feature = "websocket")]
75#[cfg_attr(docsrs, doc(cfg(feature = "websocket")))]
76pub use rig_http::ws_client;
77
78pub use completion::message;
79pub use driver::{DynModel, Model};
80pub use embeddings::Embed;
81pub use error::{ErrorKind, ErrorReport, ProviderError};
82pub use provider_response::ProviderResponseError;
83pub use schemars;
87pub use serde;
88pub use serde_json;
89
90#[cfg(feature = "derive")]
91#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
92pub use rig_derive::ContextValue;
93#[cfg(feature = "derive")]
94#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
95pub use rig_derive::Embed;
96
97#[cfg(feature = "derive")]
98#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
99pub use rig_derive::rig_tool;
100
101pub mod telemetry;
102
103pub fn millis(at: web_time::SystemTime) -> u64 {
105 at.duration_since(web_time::UNIX_EPOCH)
106 .map(|elapsed| u64::try_from(elapsed.as_millis()).unwrap_or(u64::MAX))
107 .unwrap_or_default()
108}
109
110pub fn now_ms() -> u64 {
112 millis(web_time::SystemTime::now())
113}
114
115#[cfg(not(target_family = "wasm"))]
117const _: fn() = || {
118 fn assert_send_sync_static<T: Send + Sync + 'static>() {}
119 fn assert_send_static<T: Send + 'static>() {}
120 assert_send_sync_static::<tool::ManagedToolToken>();
121 assert_send_sync_static::<streaming::StreamEvent>();
122 assert_send_sync_static::<completion::ModelRef>();
124 assert_send_sync_static::<tool::DynamicTool>();
125 assert_send_sync_static::<http_client::DynHttpClient>();
127 assert_send_static::<streaming::CompletionStream>();
130};