improved error handling

introduced toml config
This commit is contained in:
milan
2026-04-06 13:24:37 +01:00
parent 6bfadfeba7
commit 2dbac8a91a
7 changed files with 352 additions and 92 deletions
+22
View File
@@ -0,0 +1,22 @@
use crate::config::OllamaModelConfig;
use ollama_rs::Ollama;
use ollama_rs::error::OllamaError;
use ollama_rs::models::ModelOptions;
use ollama_rs::models::create::{CreateModelRequest, CreateModelStatus};
pub async fn create_model_from_config(
ollama: &Ollama,
config: &OllamaModelConfig,
) -> Result<CreateModelStatus, OllamaError> {
let model_options = ModelOptions::default()
.num_ctx(config.context_size.unwrap_or(2048))// 2048 is the ollama default.
.temperature(config.temperature.unwrap_or(0.8)); // 0.8 is the ollama default
ollama
.create_model(
CreateModelRequest::new(config.name.clone())
.from_model(config.from_model.clone())
.parameters(model_options),
)
.await
}