Crate llm_kit_huggingface

Crate llm_kit_huggingface 

Source
Expand description

§Hugging Face Provider for LLM Kit

This crate provides a Hugging Face provider implementation for the LLM Kit, supporting the Hugging Face Responses API.

§Features

  • Text generation with streaming support
  • Tool calling (function calling)
  • Multimodal inputs (text + images)
  • Reasoning content
  • Source annotations
  • Structured output (JSON schema)

§Quick Start

use llm_kit_huggingface::HuggingFaceClient;
use llm_kit_core::{GenerateText, prompt::Prompt};

#[tokio::main]
async fn main() {
    // Create provider using the client builder
    let provider = HuggingFaceClient::new()
        .api_key("your-api-key")
        .build();

    let model = provider.responses("meta-llama/Llama-3.1-8B-Instruct");

    let result = GenerateText::new(model, Prompt::text("Hello!"))
        .execute()
        .await
        .unwrap();

    println!("{}", result.text);
}

§Using Settings Directly (Alternative)

use llm_kit_huggingface::{HuggingFaceProvider, HuggingFaceProviderSettings};
use llm_kit_core::{GenerateText, prompt::Prompt};

#[tokio::main]
async fn main() {
    // Create provider using settings
    let provider = HuggingFaceProvider::new(
        HuggingFaceProviderSettings::new()
            .with_api_key("your-api-key")
    );

    let model = provider.responses("meta-llama/Llama-3.1-8B-Instruct");

    let result = GenerateText::new(model, Prompt::text("Hello!"))
        .execute()
        .await
        .unwrap();

    println!("{}", result.text);
}

Re-exports§

pub use client::HuggingFaceClient;
pub use error::HuggingFaceErrorData;
pub use error::HuggingFaceErrorDetail;
pub use provider::HuggingFaceProvider;
pub use responses::HuggingFaceResponsesModelId;
pub use responses::HuggingFaceResponsesSettings;
pub use responses::HuggingFaceResponsesTool;
pub use responses::HuggingFaceResponsesToolChoice;
pub use settings::HuggingFaceProviderSettings;
pub use responses::settings::DEEPSEEK_R1;
pub use responses::settings::DEEPSEEK_V3_1;
pub use responses::settings::GEMMA_2_9B_IT;
pub use responses::settings::KIMI_K2_INSTRUCT;
pub use responses::settings::LLAMA_3_1_8B_INSTRUCT;
pub use responses::settings::LLAMA_3_1_70B_INSTRUCT;
pub use responses::settings::LLAMA_3_3_70B_INSTRUCT;
pub use responses::settings::QWEN2_5_7B_INSTRUCT;
pub use responses::settings::QWEN3_32B;

Modules§

client
error
provider
responses
settings