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;
30mod modality_stream;
31pub mod output;
32pub mod prompt;
33#[cfg(feature = "realtime")]
34pub mod realtime;
35pub mod registry;
36pub mod rerank;
37pub mod retry;
38pub mod skills;
39pub mod speech;
40pub mod speech_translation;
41pub mod stream_text;
42pub mod telemetry;
43pub mod timeout;
44pub mod transcription;
45#[cfg(feature = "video")]
46pub mod video;
47
48pub use agent::Agent;
49pub use agent::AgentCall;
50pub use agent::ToolLoopAgent;
51pub use batch::cancel_batch;
52pub use batch::get_batch_results;
53pub use batch::get_batch_status;
54pub use batch::list_batches;
55pub use batch::start_batch;
56pub use clock::Clock;
57pub use embed::cosine_similarity;
58pub use embed::embed;
59pub use embed::embed_many;
60pub use error::Error;
61pub use error::ErrorKind;
62pub use files::upload_file;
63pub use generate_text::GenerateText;
64pub use generate_text::GenerateTextResult;
65pub use generate_text::StepContent;
66pub use generate_text::StepResult;
67pub use generate_text::generate_text;
68pub use generate_text::has_tool_call;
69pub use generate_text::step_count;
70pub use hooks::HookFn;
71pub use hooks::Hooks;
72pub use image::generate_image;
73pub use middleware::EmbeddingModelMiddleware;
74pub use middleware::ImageModelMiddleware;
75pub use middleware::LanguageModelMiddleware;
76pub use middleware::ProviderMiddleware;
77pub use middleware::wrap_embedding_model;
78pub use middleware::wrap_image_model;
79pub use middleware::wrap_language_model;
80pub use middleware::wrap_provider;
81pub use output::Output;
82pub use prompt::CallSettings;
83pub use prompt::Instructions;
84#[cfg(feature = "realtime")]
85pub use realtime::RealtimeSession;
86#[cfg(feature = "realtime")]
87pub use realtime::realtime_session;
88pub use registry::ProviderRegistry;
89pub use registry::create_provider_registry;
90pub use registry::custom_provider;
91pub use rerank::rerank;
92pub use retry::RetryPolicy;
93pub use skills::upload_skill;
94pub use speech::generate_speech;
95pub use speech_translation::stream_speech_translation;
96pub use stream_text::StreamEvent;
97pub use stream_text::StreamText;
98pub use stream_text::StreamTextResult;
99pub use stream_text::stream_text;
100pub use telemetry::Telemetry;
101pub use telemetry::TelemetryOptions;
102pub use timeout::Timeout;
103pub use transcription::stream_transcribe;
104pub use transcription::transcribe;
105#[cfg(feature = "video")]
106pub use video::generate_video;
107
108/// User-agent suffix appended to every model request.
109pub(crate) const USER_AGENT: &str = concat!("ferrin/", env!("CARGO_PKG_VERSION"));