Expand description
ollama model information fetcher.
for getting every single info about ollama models, those models are hosted on Ollama
§Examples
these examples are the most you will need to use !!
§Example 1
You can get all models names available that are hosted on the Ollama website.
use ollama_models_info_fetcher::{fetch_all_available_models, Result};
#[tokio::main]
async fn main() -> Result<()> {
// getting all models that are available on the Ollama.com !!!
let all_models = fetch_all_available_models().await?;
// iterating over all models names and printing them!
for name in all_models {
println!("{}", name);
}
Ok(())
}§Example 2
you can fetch and get a model info by feeding it a name !
use ollama_models_info_fetcher::{fetch_model_info, Result};
#[tokio::main]
async fn main() -> Result<()> {
let info = fetch_model_info("deepseek-r1").await?;
println!("{:?}", info);
Ok(())
}§Example 3
you can easily convert a model to json string!
use ollama_models_info_fetcher::{convert_to_json, fetch_model_info, Result};
#[tokio::main]
async fn main() -> Result<()> {
let model = fetch_model_info("deepseek-r1").await?;
let json = convert_to_json(&model)?;
print!("{}", json);
Ok(())
}§Example 4
this example finalize everything , here you can export every available model to json file.
use ollama_models_info_fetcher::{
convert_to_json, fetch_all_available_models, fetch_model_info, Result,
};
use std::{fs::File, io::Write};
#[tokio::main]
async fn main() -> Result<()> {
//creating json file to write into!
let mut f = File::create("./models.json")?;
let all_models = fetch_all_available_models().await?;
let mut models_info = vec![];
for model_name in all_models {
models_info.push(fetch_model_info(&model_name).await?);
}
let to_json = convert_to_json(&models_info)?;
f.write_all(to_json.as_bytes())?;
Ok(())
}Macros§
- anyhow
- Construct an ad-hoc error from a string or existing non-
anyhowerror value.
Structs§
- Model
- represents and stores the required information!
- Model
Builder - This is used to quickly building and instantiating the Model struct .
- Model
NotFound - If the model is not found on the official ollama website.
- Varient
- the tag or (token_size , size) that the model may provide ,
Enums§
- Category
- represents different tags that the model may be marked with or have the capability to perform!
Functions§
- convert_
to_ json - quick method that returns the serialized of the model to JSON format!!
- create_
selector - fetch_
all_ available_ models - returns all available ollama models that are located on : Ollama website.
- fetch_
model_ info - give it an valid existed model name and it will feed you back with all its required corresponded information!!
- get_
model_ page - if the model exist returns the corresponding page, otherwise returns error not found !!
Type Aliases§
- Result
Result<T, Error>