| @@ -0,0 +1,44 @@ | |||
| 1 | + | use future_utils::StreamExt; | |
| 2 | + | use llm_connector::{ | |
| 3 | + | LlmClient, | |
| 4 | + | types::{ChatRequest, Message, Role, MessageBlock}, | |
| 5 | + | }; | |
| 6 | + | ||
| 7 | + | use tokio::fs; | |
| 8 | + | use base64::engine::general_purpose::STANDARD; | |
| 9 | + | use base64::Engine; | |
| 10 | + | ||
| 11 | + | #[tokio::main] | |
| 12 | + | async fn main() -> Result<(), Box<dyn std::error::Error>> { | |
| 13 | + | let client = LlmClient::openai_with_base_url("", "http://192.168.0.11:1234")?; | |
| 14 | + | ||
| 15 | + | let models = client.models().await?; | |
| 16 | + | for model in models { | |
| 17 | + | println!("Available model: {}", model); | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | let data = fs::read("/home/aquafire/Downloads/14843746.jpg").await?; | |
| 21 | + | let encoded = STANDARD.encode(&data); | |
| 22 | + | ||
| 23 | + | println!("{}", encoded); | |
| 24 | + | ||
| 25 | + | ||
| 26 | + | let request = ChatRequest { | |
| 27 | + | model: "qwen/qwen3-vl-30b".to_string(), | |
| 28 | + | messages: vec![ | |
| 29 | + | Message::new( | |
| 30 | + | Role::User, | |
| 31 | + | vec![ | |
| 32 | + | MessageBlock::text("Analyze this image"), | |
| 33 | + | MessageBlock::image_base64("image/jpeg", encoded), | |
| 34 | + | ], | |
| 35 | + | ), | |
| 36 | + | ], | |
| 37 | + | ..Default::default() | |
| 38 | + | }; | |
| 39 | + | ||
| 40 | + | let response = client.chat(&request).await?; | |
| 41 | + | println!("Response: {}", response.content); | |
| 42 | + | ||
| 43 | + | Ok(()) | |
| 44 | + | } | |
aquafire / multimodal.rs
Last active 6 months ago
aquafire revised this gist 11 months ago · a2074c8
1 file changed, 44 insertions