diff --git a/pets-gd/.gitignore b/pets-gd/.gitignore index 47091836..7f907739 100644 --- a/pets-gd/.gitignore +++ b/pets-gd/.gitignore @@ -1,2 +1,10 @@ +# Source: +# https://huggingface.co/rustformers/bloom-ggml +# https://huggingface.co/models?other=llm-rs +# +# This specific model is from +# https://huggingface.co/rustformers/bloom-ggml/blob/main/bloom-1b7-q4_0.bin +assets/llm.bin + # Godot 4+ specific ignores .godot/ diff --git a/pets-lib/src/llm/mod.rs b/pets-lib/src/llm/mod.rs index 5d552ad0..338151fa 100644 --- a/pets-lib/src/llm/mod.rs +++ b/pets-lib/src/llm/mod.rs @@ -1,9 +1,24 @@ use crate::prelude::*; use io::Write; -use llm::models::Gpt2; -fn load_llm() -> Gpt2 { +use llm::models::Bloom; +use llm::Model as _; +use llm::{InferenceFeedback, InferenceResponse, Prompt}; + +/// get the path of the pretrained model +fn get_llm_path() -> Result { + // Open file in read mode + let model_file = GFile::open("res://assets/llm.bin", ModeFlags::READ)?; + + let path = model_file.path_absolute().to_string(); + + path.parse() + .map_err(|e| anyhow!("Failed to parse path: {}", e)) +} + +fn load_llm() -> Bloom { + let model_path = get_llm_path().unwrap(); // load a GGML model from disk llm::load( Path::new("/path/to/model"),