mirror of
https://github.com/zenlm/engine.git
synced 2026-10-30 15:00:05 +00:00
* Initial * Markdown * Copy code * Add model loading sidebar * Support vision models * Tweak isq * Links go to another page * Clear when switch model * Fix html tags * Add image support! * More then one images * Fix * Improved textarea * Tab for switching between vision and text * No paged attn for now * Prettier format * Multiple models at once * Better switching, clearing ability * Mobile support * Inline markdown parser * Update examples * Typos * Support specifying isq * Fix mobile * Fixes * Fix button on mobile * Image height is capped * Thumbnail * Fix rotating kv cache edge case * Add drag and drop for images * Small things * Sidebar is frozen now * Better listner * Add readme * Tweak readme
37 lines
1.0 KiB
Rust
37 lines
1.0 KiB
Rust
use anyhow::Result;
|
|
use mistralrs::{IsqType, TextMessageRole, VisionMessages, VisionModelBuilder};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let model = VisionModelBuilder::new("google/gemma-3-12b-it")
|
|
.with_isq(IsqType::Q4K)
|
|
.with_logging()
|
|
.build()
|
|
.await?;
|
|
|
|
let bytes = match reqwest::blocking::get(
|
|
"https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg",
|
|
) {
|
|
Ok(http_resp) => http_resp.bytes()?.to_vec(),
|
|
Err(e) => anyhow::bail!(e),
|
|
};
|
|
let image = image::load_from_memory(&bytes)?;
|
|
|
|
let messages = VisionMessages::new().add_image_message(
|
|
TextMessageRole::User,
|
|
"What is this?",
|
|
vec![image],
|
|
&model,
|
|
)?;
|
|
|
|
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(())
|
|
}
|