1use anyhow::Result;
2use mistralrs::{IsqType, TextMessageRole, TextMessages, TextModelBuilder};
3
4#[tokio::main]
5async fn main() -> Result<()> {
6 let model = TextModelBuilder::new("zai-org/GLM-4.7-Flash")
7 .with_isq(IsqType::Q4K)
8 .with_logging()
9 .build()
10 .await?;
11
12 let messages = TextMessages::new()
13 .add_message(
14 TextMessageRole::System,
15 "You are an AI agent with a specialty in programming.",
16 )
17 .add_message(
18 TextMessageRole::User,
19 "Hello! How are you? Please write generic binary search function in Rust.",
20 );
21
22 let response = model.send_chat_request(messages).await?;
23
24 println!("{}", response.choices[0].message.content.as_ref().unwrap());
25 dbg!(
26 response.usage.avg_prompt_tok_per_sec,
27 response.usage.avg_compl_tok_per_sec
28 );
29
30 Ok(())
31}