Adds pull method and example
This commit is contained in:
22
examples/pull.rs
Normal file
22
examples/pull.rs
Normal 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(())
|
||||
}
|
||||
Reference in New Issue
Block a user