Skip to main content

openvino_genai/
lib.rs

1//! The [openvino-genai] crate provides high-level, ergonomic, safe Rust bindings to OpenVINO GenAI.
2//! See the repository [README] for more information, such as build instructions.
3//!
4//! [openvino-genai]: https://crates.io/crates/openvino-genai
5//! [README]: https://github.com/intel/openvino-rs
6//!
7//! Most interaction with OpenVINO GenAI begins with instantiating an [`LlmPipeline`]:
8//! ```no_run
9//! let pipeline = openvino_genai::LlmPipeline::new("path/to/model", "CPU")
10//!     .expect("to create an LLM pipeline");
11//! ```
12
13#![deny(missing_docs)]
14#![deny(clippy::all)]
15#![warn(clippy::pedantic)]
16#![warn(clippy::cargo)]
17#![allow(
18    clippy::must_use_candidate,
19    clippy::module_name_repetitions,
20    clippy::missing_errors_doc,
21    clippy::len_without_is_empty,
22    clippy::doc_markdown
23)]
24
25mod chat_history;
26mod chat_message;
27mod decoded_results;
28mod error;
29mod generation_config;
30mod json_container;
31mod llm_pipeline;
32mod perf_metrics;
33mod streamer;
34mod util;
35mod vlm_pipeline;
36mod whisper_generation_config;
37mod whisper_pipeline;
38
39pub use error::{InferenceError, LoadingError, SetupError};
40
41/// Load the OpenVINO GenAI shared library using automatic discovery.
42///
43/// If the library has already been loaded, this is a no-op.
44/// Delegates to [`openvino_genai_sys::library::load`].
45pub fn load() -> Result<(), String> {
46    openvino_genai_sys::library::load()
47}
48
49/// Load the OpenVINO GenAI shared library from an explicit path.
50///
51/// The `path` should point to the `openvino_genai_c` shared library file
52/// (e.g., `libopenvino_genai_c.so`).
53/// Delegates to [`openvino_genai_sys::library::load_from`].
54pub fn load_from(path: impl Into<std::path::PathBuf>) -> Result<(), String> {
55    openvino_genai_sys::library::load_from(path)
56}
57pub use chat_history::ChatHistory;
58pub use chat_message::{ChatMessage, ToolCall};
59pub use decoded_results::DecodedResults;
60pub use generation_config::GenerationConfig;
61pub use json_container::JsonContainer;
62pub use llm_pipeline::LlmPipeline;
63pub use perf_metrics::PerfMetrics;
64pub use streamer::{Streamer, StreamingStatus};
65pub use vlm_pipeline::{VlmDecodedResults, VlmPipeline};
66pub use whisper_generation_config::WhisperGenerationConfig;
67pub use whisper_pipeline::{WhisperDecodedResultChunk, WhisperDecodedResults, WhisperPipeline};