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
43#[cfg(feature = "audio")]
44#[cfg_attr(docsrs, doc(cfg(feature = "audio")))]
45pub mod audio_generation;
46pub mod catalog;
47pub mod client;
48pub mod completion;
49pub mod conversation;
50pub mod driver;
51pub mod effect;
52pub mod embeddings;
53pub mod error;
54pub use rig_http::http_client;
55pub mod id;
56#[cfg(feature = "image")]
57#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
58pub mod image_generation;
59#[doc(hidden)]
62pub mod json_utils;
63pub mod loaders;
64pub mod markers;
65pub mod model;
66pub mod observe;
67pub mod operation;
68pub mod prelude;
69pub(crate) mod provider_response;
70pub mod providers;
71pub mod redact;
72pub mod rerank;
73pub mod serve;
74
75pub mod streaming;
76pub mod structured_output;
77#[cfg(any(test, feature = "test-utils"))]
78#[cfg_attr(docsrs, doc(cfg(feature = "test-utils")))]
79pub mod test_utils;
80pub mod tool;
81pub mod transcription;
82pub mod vector_store;
83pub use rig_http::wasm_compat;
84pub mod wire;
85#[cfg(feature = "websocket")]
86#[cfg_attr(docsrs, doc(cfg(feature = "websocket")))]
87pub use rig_http::ws_client;
88
89pub use completion::message;
90pub use driver::{DynModel, Model};
91pub use embeddings::Embed;
92pub use error::{ErrorKind, ErrorReport, ProviderError};
93pub use provider_response::ProviderResponseError;
94pub use schemars;
98pub use serde;
99pub use serde_json;
100
101#[cfg(feature = "derive")]
102#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
103pub use rig_derive::ContextValue;
104#[cfg(feature = "derive")]
105#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
106pub use rig_derive::Embed;
107
108#[cfg(feature = "derive")]
109#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
110pub use rig_derive::rig_tool;
111
112pub mod telemetry;
113
114pub fn millis(at: web_time::SystemTime) -> u64 {
116 at.duration_since(web_time::UNIX_EPOCH)
117 .map(|elapsed| u64::try_from(elapsed.as_millis()).unwrap_or(u64::MAX))
118 .unwrap_or_default()
119}
120
121pub fn now_ms() -> u64 {
123 millis(web_time::SystemTime::now())
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};