llm_kit_huggingface/
lib.rs

1//! # Hugging Face Provider for LLM Kit
2//!
3//! This crate provides a Hugging Face provider implementation for the LLM Kit,
4//! supporting the Hugging Face Responses API.
5//!
6//! ## Features
7//!
8//! - Text generation with streaming support
9//! - Tool calling (function calling)
10//! - Multimodal inputs (text + images)
11//! - Reasoning content
12//! - Source annotations
13//! - Structured output (JSON schema)
14//!
15//! ## Quick Start
16//!
17//! ### Using the Client Builder (Recommended)
18//!
19//! ```ignore
20//! use llm_kit_huggingface::HuggingFaceClient;
21//! use llm_kit_core::{GenerateText, prompt::Prompt};
22//!
23//! #[tokio::main]
24//! async fn main() {
25//!     // Create provider using the client builder
26//!     let provider = HuggingFaceClient::new()
27//!         .api_key("your-api-key")
28//!         .build();
29//!
30//!     let model = provider.responses("meta-llama/Llama-3.1-8B-Instruct");
31//!
32//!     let result = GenerateText::new(model, Prompt::text("Hello!"))
33//!         .execute()
34//!         .await
35//!         .unwrap();
36//!
37//!     println!("{}", result.text);
38//! }
39//! ```
40//!
41//! ### Using Settings Directly (Alternative)
42//!
43//! ```ignore
44//! use llm_kit_huggingface::{HuggingFaceProvider, HuggingFaceProviderSettings};
45//! use llm_kit_core::{GenerateText, prompt::Prompt};
46//!
47//! #[tokio::main]
48//! async fn main() {
49//!     // Create provider using settings
50//!     let provider = HuggingFaceProvider::new(
51//!         HuggingFaceProviderSettings::new()
52//!             .with_api_key("your-api-key")
53//!     );
54//!
55//!     let model = provider.responses("meta-llama/Llama-3.1-8B-Instruct");
56//!
57//!     let result = GenerateText::new(model, Prompt::text("Hello!"))
58//!         .execute()
59//!         .await
60//!         .unwrap();
61//!
62//!     println!("{}", result.text);
63//! }
64//! ```
65
66pub mod client;
67pub mod error;
68pub mod provider;
69pub mod responses;
70pub mod settings;
71
72// Re-exports
73pub use client::HuggingFaceClient;
74pub use error::{HuggingFaceErrorData, HuggingFaceErrorDetail};
75pub use provider::HuggingFaceProvider;
76pub use responses::{
77    HuggingFaceResponsesModelId, HuggingFaceResponsesSettings, HuggingFaceResponsesTool,
78    HuggingFaceResponsesToolChoice,
79};
80pub use settings::HuggingFaceProviderSettings;
81
82// Re-export common model constants
83pub use responses::settings::{
84    DEEPSEEK_R1, DEEPSEEK_V3_1, GEMMA_2_9B_IT, KIMI_K2_INSTRUCT, LLAMA_3_1_8B_INSTRUCT,
85    LLAMA_3_1_70B_INSTRUCT, LLAMA_3_3_70B_INSTRUCT, QWEN2_5_7B_INSTRUCT, QWEN3_32B,
86};