Adds pull method and example

This commit is contained in:
2025-12-28 12:18:35 +00:00
parent 65ea1dcfec
commit ac480881e4
6 changed files with 111 additions and 5 deletions

22
examples/pull.rs Normal file
View File

@@ -0,0 +1,22 @@
use std::{env, error::Error, io::Write};
use futures_util::StreamExt;
use ollama_rs::{OllamaClient, types::pull::PullRequest};
const MODEL: &str = "HammerAI/mythomax-l2";
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let _ = dotenvy::dotenv();
let server_address = env::var("OLLAMA_SERVER")?;
let ollama_client = OllamaClient::new(server_address);
let request = PullRequest::builder(MODEL).stream(true).build();
let mut stream = ollama_client.pull(request).await;
while let Some(response) = stream.next().await {
let response = response?;
println!("{:?}", response);
std::io::stdout().flush()?;
}
Ok(())
}