Skip to content

Commit

Permalink
cargo fmt --all
Browse files Browse the repository at this point in the history
  • Loading branch information
zees-dev committed Feb 18, 2025
1 parent 2d6d97b commit b7ae358
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 64 deletions.
10 changes: 5 additions & 5 deletions crates/blockless-drivers/src/llm_driver/llamafile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ mod tests {

#[test]
fn test_model_parsing() {
assert!(SupportedModels::from_str("Llama-3.2-1B-Instruct").is_ok());
assert!(SupportedModels::from_str("Llama-3.2-1B-Instruct-Q6_K").is_ok());
assert!(SupportedModels::from_str("Llama-3.2-1B-Instruct").is_ok());
assert!(SupportedModels::from_str("Llama-3.2-1B-Instruct-Q6_K").is_ok());

assert!(SupportedModels::from_str("Llama-3.2-3B-Instruct").is_ok());
assert!(SupportedModels::from_str("Llama-3.2-3B-Instruct-Q6_K").is_ok());
assert!(SupportedModels::from_str("unsupported-model").is_err());
assert!(SupportedModels::from_str("Llama-3.2-3B-Instruct").is_ok());
assert!(SupportedModels::from_str("Llama-3.2-3B-Instruct-Q6_K").is_ok());
assert!(SupportedModels::from_str("unsupported-model").is_err());
}
}
118 changes: 59 additions & 59 deletions crates/blockless-drivers/src/llm_driver/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,74 +63,74 @@ impl SupportedModels {
}

impl FromStr for SupportedModels {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
// Llama 3.2 1B
"Llama-3.2-1B-Instruct" => Ok(SupportedModels::Llama321BInstruct(None)),
"Llama-3.2-1B-Instruct-Q6_K"
| "Llama-3.2-1B-Instruct_Q6_K"
| "Llama-3.2-1B-Instruct.Q6_K" => {
Ok(SupportedModels::Llama321BInstruct(Some("Q6_K".to_string())))
}
"Llama-3.2-1B-Instruct-q4f16_1" | "Llama-3.2-1B-Instruct.q4f16_1" => Ok(
SupportedModels::Llama321BInstruct(Some("q4f16_1".to_string())),
),
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
// Llama 3.2 1B
"Llama-3.2-1B-Instruct" => Ok(SupportedModels::Llama321BInstruct(None)),
"Llama-3.2-1B-Instruct-Q6_K"
| "Llama-3.2-1B-Instruct_Q6_K"
| "Llama-3.2-1B-Instruct.Q6_K" => {
Ok(SupportedModels::Llama321BInstruct(Some("Q6_K".to_string())))
}
"Llama-3.2-1B-Instruct-q4f16_1" | "Llama-3.2-1B-Instruct.q4f16_1" => Ok(
SupportedModels::Llama321BInstruct(Some("q4f16_1".to_string())),
),

// Llama 3.2 3B
"Llama-3.2-3B-Instruct" => Ok(SupportedModels::Llama323BInstruct(None)),
"Llama-3.2-3B-Instruct-Q6_K"
| "Llama-3.2-3B-Instruct_Q6_K"
| "Llama-3.2-3B-Instruct.Q6_K" => {
Ok(SupportedModels::Llama323BInstruct(Some("Q6_K".to_string())))
}
"Llama-3.2-3B-Instruct-q4f16_1" | "Llama-3.2-3B-Instruct.q4f16_1" => Ok(
SupportedModels::Llama323BInstruct(Some("q4f16_1".to_string())),
),
// Llama 3.2 3B
"Llama-3.2-3B-Instruct" => Ok(SupportedModels::Llama323BInstruct(None)),
"Llama-3.2-3B-Instruct-Q6_K"
| "Llama-3.2-3B-Instruct_Q6_K"
| "Llama-3.2-3B-Instruct.Q6_K" => {
Ok(SupportedModels::Llama323BInstruct(Some("Q6_K".to_string())))
}
"Llama-3.2-3B-Instruct-q4f16_1" | "Llama-3.2-3B-Instruct.q4f16_1" => Ok(
SupportedModels::Llama323BInstruct(Some("q4f16_1".to_string())),
),

// Mistral 7B
"Mistral-7B-Instruct-v0.3" => Ok(SupportedModels::Mistral7BInstructV03(None)),
"Mistral-7B-Instruct-v0.3-q4f16_1" | "Mistral-7B-Instruct-v0.3.q4f16_1" => Ok(
SupportedModels::Mistral7BInstructV03(Some("q4f16_1".to_string())),
),
// Mistral 7B
"Mistral-7B-Instruct-v0.3" => Ok(SupportedModels::Mistral7BInstructV03(None)),
"Mistral-7B-Instruct-v0.3-q4f16_1" | "Mistral-7B-Instruct-v0.3.q4f16_1" => Ok(
SupportedModels::Mistral7BInstructV03(Some("q4f16_1".to_string())),
),

// Mixtral 8x7B
"Mixtral-8x7B-Instruct-v0.1" => Ok(SupportedModels::Mixtral8x7BInstructV01(None)),
"Mixtral-8x7B-Instruct-v0.1-q4f16_1" | "Mixtral-8x7B-Instruct-v0.1.q4f16_1" => Ok(
SupportedModels::Mixtral8x7BInstructV01(Some("q4f16_1".to_string())),
),
// Mixtral 8x7B
"Mixtral-8x7B-Instruct-v0.1" => Ok(SupportedModels::Mixtral8x7BInstructV01(None)),
"Mixtral-8x7B-Instruct-v0.1-q4f16_1" | "Mixtral-8x7B-Instruct-v0.1.q4f16_1" => Ok(
SupportedModels::Mixtral8x7BInstructV01(Some("q4f16_1".to_string())),
),

// Gemma models
"gemma-2-2b-it" => Ok(SupportedModels::Gemma22BInstruct(None)),
"gemma-2-2b-it-q4f16_1" | "gemma-2-2b-it.q4f16_1" => Ok(
SupportedModels::Gemma22BInstruct(Some("q4f16_1".to_string())),
),
// Gemma models
"gemma-2-2b-it" => Ok(SupportedModels::Gemma22BInstruct(None)),
"gemma-2-2b-it-q4f16_1" | "gemma-2-2b-it.q4f16_1" => Ok(
SupportedModels::Gemma22BInstruct(Some("q4f16_1".to_string())),
),

"gemma-2-27b-it" => Ok(SupportedModels::Gemma27BInstruct(None)),
"gemma-2-27b-it-q4f16_1" | "gemma-2-27b-it.q4f16_1" => Ok(
SupportedModels::Gemma27BInstruct(Some("q4f16_1".to_string())),
),
"gemma-2-27b-it" => Ok(SupportedModels::Gemma27BInstruct(None)),
"gemma-2-27b-it-q4f16_1" | "gemma-2-27b-it.q4f16_1" => Ok(
SupportedModels::Gemma27BInstruct(Some("q4f16_1".to_string())),
),

"gemma-2-9b-it" => Ok(SupportedModels::Gemma29BInstruct(None)),
"gemma-2-9b-it-q4f16_1" | "gemma-2-9b-it.q4f16_1" => Ok(
SupportedModels::Gemma29BInstruct(Some("q4f16_1".to_string())),
),
"gemma-2-9b-it" => Ok(SupportedModels::Gemma29BInstruct(None)),
"gemma-2-9b-it-q4f16_1" | "gemma-2-9b-it.q4f16_1" => Ok(
SupportedModels::Gemma29BInstruct(Some("q4f16_1".to_string())),
),

_ => Err(format!("Unsupported model: {}", s)),
}
}
_ => Err(format!("Unsupported model: {}", s)),
}
}
}

impl ToString for SupportedModels {
fn to_string(&self) -> String {
match self {
SupportedModels::Llama321BInstruct(_) => "Llama-3.2-1B-Instruct".to_string(),
SupportedModels::Llama323BInstruct(_) => "Llama-3.2-3B-Instruct".to_string(),
SupportedModels::Mistral7BInstructV03(_) => "Mistral-7B-Instruct-v0.3".to_string(),
SupportedModels::Mixtral8x7BInstructV01(_) => "Mixtral-8x7B-Instruct-v0.1".to_string(),
SupportedModels::Gemma22BInstruct(_) => "gemma-2-2b-it".to_string(),
SupportedModels::Gemma27BInstruct(_) => "gemma-2-27b-it".to_string(),
SupportedModels::Gemma29BInstruct(_) => "gemma-2-9b-it".to_string(),
fn to_string(&self) -> String {
match self {
SupportedModels::Llama321BInstruct(_) => "Llama-3.2-1B-Instruct".to_string(),
SupportedModels::Llama323BInstruct(_) => "Llama-3.2-3B-Instruct".to_string(),
SupportedModels::Mistral7BInstructV03(_) => "Mistral-7B-Instruct-v0.3".to_string(),
SupportedModels::Mixtral8x7BInstructV01(_) => "Mixtral-8x7B-Instruct-v0.1".to_string(),
SupportedModels::Gemma22BInstruct(_) => "gemma-2-2b-it".to_string(),
SupportedModels::Gemma27BInstruct(_) => "gemma-2-27b-it".to_string(),
SupportedModels::Gemma29BInstruct(_) => "gemma-2-9b-it".to_string(),
}
}
}
}

0 comments on commit b7ae358

Please sign in to comment.