improved error handling
introduced toml config
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user