From 58e6c9f36f97d0a3e287b97256dc5f6b0e9fb5ae Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sat, 25 Mar 2023 01:26:28 -0400 Subject: Add support for file load progress reporting callbacks (#434) * File load progress reporting * Move llama_progress_handler into llama_context_params * Renames * Use seekg to find file size instead * More correct load progress * Call progress callback more frequently * Fix typo --- llama.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llama.h') diff --git a/llama.h b/llama.h index 57123dbc..827abc1f 100644 --- a/llama.h +++ b/llama.h @@ -45,6 +45,8 @@ extern "C" { } llama_token_data; + typedef void (*llama_progress_callback)(double progress, void *ctx); + struct llama_context_params { int n_ctx; // text context int n_parts; // -1 for default @@ -55,6 +57,11 @@ extern "C" { bool vocab_only; // only load the vocabulary, no weights bool use_mlock; // force system to keep model in RAM bool embedding; // embedding mode only + + // called with a progress value between 0 and 1, pass NULL to disable + llama_progress_callback progress_callback; + // context pointer passed to the progress callback + void * progress_callback_user_data; }; LLAMA_API struct llama_context_params llama_context_default_params(); -- cgit v1.2.3