Skip to main content

rig_core/providers/huggingface/
completion.rs

1use super::client::HuggingFaceExt;
2use crate::providers::openai;
3use serde::Deserialize;
4use serde_json::Value;
5
6#[derive(Debug, Deserialize)]
7#[serde(untagged)]
8pub enum ApiResponse<T> {
9    Ok(T),
10    Err(Value),
11}
12
13// ================================================================
14// Huggingface Completion API
15// ================================================================
16
17// Conversational LLMs
18/// `google/gemma-2-2b-it` completion model
19pub const GEMMA_2: &str = "google/gemma-2-2b-it";
20/// `meta-llama/Meta-Llama-3.1-8B-Instruct` completion model
21pub const META_LLAMA_3_1: &str = "meta-llama/Meta-Llama-3.1-8B-Instruct";
22/// `PowerInfer/SmallThinker-3B-Preview` completion model
23pub const SMALLTHINKER_PREVIEW: &str = "PowerInfer/SmallThinker-3B-Preview";
24/// `Qwen/Qwen2.5-7B-Instruct` completion model
25pub const QWEN2_5: &str = "Qwen/Qwen2.5-7B-Instruct";
26/// `Qwen/Qwen2.5-Coder-32B-Instruct` completion model
27pub const QWEN2_5_CODER: &str = "Qwen/Qwen2.5-Coder-32B-Instruct";
28
29// Conversational VLMs
30
31/// `Qwen/Qwen2-VL-7B-Instruct` visual-language completion model
32pub const QWEN2_VL: &str = "Qwen/Qwen2-VL-7B-Instruct";
33/// `Qwen/QVQ-72B-Preview` visual-language completion model
34pub const QWEN_QVQ_PREVIEW: &str = "Qwen/QVQ-72B-Preview";
35
36/// Huggingface completion model, driven by the shared OpenAI Chat Completions
37/// path. The sub-provider's completion endpoint and model-identifier mapping
38/// are applied by [`HuggingFaceExt`]'s `OpenAICompatibleProvider` impl.
39pub type CompletionModel<H = reqwest::Client> =
40    openai::completion::GenericCompletionModel<HuggingFaceExt, H>;
41
42/// Raw completion payload, shared with the OpenAI Chat Completions path.
43pub type CompletionResponse = openai::CompletionResponse;