Skip to main content

ferrin_core/
lib.rs

1//! Ferrin core.
2//!
3//! Text generation loop, streaming pipeline, structured output, agents,
4//! middleware, provider registry, retry and timeout policies, and the other
5//! modalities (embeddings, images, speech, transcription, reranking, video).
6//!
7//! Design: `docs/01-architecture/07-generation-loop-and-streaming.md` and following.
8//!
9//! # Attribution
10//!
11//! Portions of this crate are derived from the Vercel AI SDK (Apache-2.0,
12//! Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and
13//! modified. See the `NOTICE` file in the crate root.
14
15pub mod agent;
16pub mod batch;
17mod builder;
18pub(crate) mod cancel;
19pub mod clock;
20pub mod embed;
21pub mod error;
22pub mod files;
23pub mod generate_text;
24pub mod hooks;
25pub mod ids;
26pub mod image;
27pub(crate) mod limits;
28pub mod middleware;
29pub(crate) mod modality;
30pub mod output;
31pub mod prompt;
32#[cfg(feature = "realtime")]
33pub mod realtime;
34pub mod registry;
35pub mod rerank;
36pub mod retry;
37pub mod skills;
38pub mod speech;
39pub mod speech_translation;
40pub mod stream_text;
41pub mod telemetry;
42pub mod timeout;
43pub mod transcription;
44#[cfg(feature = "video")]
45pub mod video;
46
47pub use agent::Agent;
48pub use agent::AgentCall;
49pub use agent::ToolLoopAgent;
50pub use batch::cancel_batch;
51pub use batch::get_batch_results;
52pub use batch::get_batch_status;
53pub use batch::list_batches;
54pub use batch::start_batch;
55pub use clock::Clock;
56pub use embed::cosine_similarity;
57pub use embed::embed;
58pub use embed::embed_many;
59pub use error::Error;
60pub use error::ErrorKind;
61pub use files::upload_file;
62pub use generate_text::GenerateText;
63pub use generate_text::GenerateTextResult;
64pub use generate_text::StepContent;
65pub use generate_text::StepResult;
66pub use generate_text::generate_text;
67pub use generate_text::has_tool_call;
68pub use generate_text::step_count;
69pub use hooks::HookFn;
70pub use hooks::Hooks;
71pub use image::generate_image;
72pub use middleware::LanguageModelMiddleware;
73pub use middleware::wrap_language_model;
74pub use output::Output;
75pub use prompt::CallSettings;
76pub use prompt::Instructions;
77#[cfg(feature = "realtime")]
78pub use realtime::RealtimeSession;
79#[cfg(feature = "realtime")]
80pub use realtime::realtime_session;
81pub use registry::ProviderRegistry;
82pub use registry::create_provider_registry;
83pub use registry::custom_provider;
84pub use rerank::rerank;
85pub use retry::RetryPolicy;
86pub use skills::upload_skill;
87pub use speech::generate_speech;
88pub use speech_translation::stream_speech_translation;
89pub use stream_text::StreamEvent;
90pub use stream_text::StreamText;
91pub use stream_text::StreamTextResult;
92pub use stream_text::stream_text;
93pub use telemetry::Telemetry;
94pub use telemetry::TelemetryOptions;
95pub use timeout::Timeout;
96pub use transcription::stream_transcribe;
97pub use transcription::transcribe;
98#[cfg(feature = "video")]
99pub use video::generate_video;
100
101/// User-agent suffix appended to every model request.
102pub(crate) const USER_AGENT: &str = concat!("ferrin/", env!("CARGO_PKG_VERSION"));