Expand description
Ferrin core.
Text generation loop, streaming pipeline, structured output, agents, middleware, provider registry, retry and timeout policies, and the other modalities (embeddings, images, speech, transcription, reranking, video).
Design: docs/01-architecture/07-generation-loop-and-streaming.md and following.
§Attribution
Portions of this crate are derived from the Vercel AI SDK (Apache-2.0,
Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and
modified. See the NOTICE file in the crate root.
Re-exports§
pub use agent::Agent;pub use agent::AgentCall;pub use agent::ToolLoopAgent;pub use batch::cancel_batch;pub use batch::get_batch_results;pub use batch::get_batch_status;pub use batch::list_batches;pub use batch::start_batch;pub use clock::Clock;pub use embed::cosine_similarity;pub use embed::embed;pub use embed::embed_many;pub use error::Error;pub use error::ErrorKind;pub use files::upload_file;pub use generate_text::GenerateText;pub use generate_text::GenerateTextResult;pub use generate_text::StepContent;pub use generate_text::StepResult;pub use generate_text::generate_text;pub use generate_text::has_tool_call;pub use generate_text::step_count;pub use hooks::HookFn;pub use hooks::Hooks;pub use image::generate_image;pub use middleware::EmbeddingModelMiddleware;pub use middleware::ImageModelMiddleware;pub use middleware::LanguageModelMiddleware;pub use middleware::ProviderMiddleware;pub use middleware::wrap_embedding_model;pub use middleware::wrap_image_model;pub use middleware::wrap_language_model;pub use middleware::wrap_provider;pub use output::Output;pub use prompt::CallSettings;pub use prompt::Instructions;pub use realtime::RealtimeSession;pub use realtime::realtime_session;pub use registry::ProviderRegistry;pub use registry::create_provider_registry;pub use registry::custom_provider;pub use rerank::rerank;pub use retry::RetryPolicy;pub use skills::upload_skill;pub use speech::generate_speech;pub use speech_translation::stream_speech_translation;pub use stream_text::StreamEvent;pub use stream_text::StreamText;pub use stream_text::StreamTextResult;pub use stream_text::stream_text;pub use telemetry::Telemetry;pub use telemetry::TelemetryOptions;pub use timeout::Timeout;pub use transcription::stream_transcribe;pub use transcription::transcribe;pub use video::generate_video;
Modules§
- agent
- Agents: reusable configurations of the generation loop.
- batch
- Batch processing:
start_batch,get_batch_status,get_batch_results,cancel_batchandlist_batches. - clock
- Wall-clock source for response timestamps.
- embed
- Embeddings:
embedfor one value,embed_manyfor several (split into provider calls by the model’s limits) andcosine_similarity. - error
- Core error type: the single
#[non_exhaustive]enum applications see. - files
- Provider file storage:
upload_file,get_file_metadata,download_fileanddelete_file. - generate_
text - Multi-step text generation (
generate_text). - hooks
- Lifecycle hooks: asynchronous callbacks awaited by the core.
- ids
- Identifier generation for calls and approvals.
- image
- Image generation:
generate_imagesplitsnimages into provider calls, runs them concurrently and retries empty results. - middleware
- Model middleware.
- output
- Structured output strategies for
generate_textandstream_text. - prompt
- Prompt standardization and conversion to the provider prompt.
- realtime
- Realtime (WebSocket) sessions.
- registry
- Provider registry and custom providers.
- rerank
- Reranking:
rerankorders documents by relevance to a query. - retry
- Retry policy and the retry loop used around provider calls.
- skills
- Provider skill storage:
upload_skill. - speech
- Speech synthesis:
generate_speech. - speech_
translation - Speech translation (streaming only):
stream_speech_translation. - stream_
text - Streaming text generation (
stream_text). - telemetry
- Telemetry: lifecycle callbacks, options and the built-in
tracingspans. - timeout
- Timeout configuration.
- transcription
- Transcription:
transcribefor complete audio (bytes or URL) andstream_transcribefor live audio. - video
- Video generation (feature
video):generate_videosupports the synchronous flow (do_generate) and the asynchronous flow (do_start/do_status, with polling or a webhook).