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;
42
43pub mod audio_generation;
44pub mod catalog;
45pub mod client;
46pub mod completion;
47pub mod conversation;
48pub mod driver;
49pub mod effect;
50pub mod embeddings;
51pub mod error;
52pub use rig_http::http_client;
53pub mod id;
54pub mod image_generation;
55#[doc(hidden)]
58pub mod json_utils;
59pub mod loaders;
60pub mod markers;
61pub mod model;
62pub mod operation;
63pub mod prelude;
64pub(crate) mod provider_response;
65pub mod providers;
66pub mod redact;
67pub mod rerank;
68pub mod serve;
69
70pub mod streaming;
71pub mod structured_output;
72#[cfg(any(test, feature = "test-utils"))]
73#[cfg_attr(docsrs, doc(cfg(feature = "test-utils")))]
74pub mod test_utils;
75pub mod tool;
76pub mod transcription;
77pub mod vector_store;
78pub use rig_http::wasm_compat;
79pub mod wire;
80pub use rig_http::ws_client;
81
82pub use completion::message;
83pub use driver::{DynModel, Model};
84pub use embeddings::Embed;
85pub use error::{ErrorKind, ErrorReport, ProviderError};
86pub use provider_response::ProviderResponseError;
87pub use schemars;
91pub use serde;
92pub use serde_json;
93
94#[cfg(feature = "derive")]
95#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
96pub use rig_derive::ContextValue;
97#[cfg(feature = "derive")]
98#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
99pub use rig_derive::Embed;
100
101#[cfg(feature = "derive")]
102#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
103pub use rig_derive::rig_tool;
104
105pub mod telemetry;
106
107pub fn millis(at: web_time::SystemTime) -> u64 {
109 at.duration_since(web_time::UNIX_EPOCH)
110 .map(|elapsed| u64::try_from(elapsed.as_millis()).unwrap_or(u64::MAX))
111 .unwrap_or_default()
112}
113
114pub fn now_ms() -> u64 {
116 millis(web_time::SystemTime::now())
117}
118
119pub(crate) fn lock<T>(mutex: &std::sync::Mutex<T>) -> std::sync::MutexGuard<'_, T> {
121 mutex
122 .lock()
123 .unwrap_or_else(std::sync::PoisonError::into_inner)
124}
125
126#[cfg(not(target_family = "wasm"))]
128const _: fn() = || {
129 fn assert_send_sync_static<T: Send + Sync + 'static>() {}
130 fn assert_send_static<T: Send + 'static>() {}
131 assert_send_sync_static::<tool::ManagedToolToken>();
132 assert_send_sync_static::<streaming::StreamEvent>();
133 assert_send_sync_static::<completion::ModelRef>();
135 assert_send_sync_static::<tool::DynamicTool>();
136 assert_send_sync_static::<http_client::DynHttpClient>();
138 assert_send_static::<streaming::CompletionStream>();
141};