mirror of
https://github.com/zenlm/engine.git
synced 2026-10-30 15:00:05 +00:00
* Add anymoe support * Support passing DeviceMapMetadata * Update Cargo.toml * Typos
35 lines
992 B
Rust
35 lines
992 B
Rust
use anyhow::Result;
|
|
use mistralrs::{GgufModelBuilder, TextMessageRole, TextMessages};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let model = GgufModelBuilder::new(
|
|
"bartowski/Meta-Llama-3.1-8B-Instruct-GGUF",
|
|
vec!["Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf"],
|
|
)
|
|
.with_tok_model_id("meta-llama/Meta-Llama-3.1-8B-Instruct")
|
|
.with_logging()
|
|
.build()
|
|
.await?;
|
|
|
|
let messages = TextMessages::new()
|
|
.add_message(
|
|
TextMessageRole::System,
|
|
"You are an AI agent with a specialty in programming.",
|
|
)
|
|
.add_message(
|
|
TextMessageRole::User,
|
|
"Hello! How are you? Please write generic binary search function in Rust.",
|
|
);
|
|
|
|
let response = model.send_chat_request(messages).await?;
|
|
|
|
println!("{}", response.choices[0].message.content.as_ref().unwrap());
|
|
dbg!(
|
|
response.usage.avg_prompt_tok_per_sec,
|
|
response.usage.avg_compl_tok_per_sec
|
|
);
|
|
|
|
Ok(())
|
|
}
|