@@ -158,6 +158,25 @@ class llama_token_data_array(Structure):
158
158
llama_progress_callback = ctypes .CFUNCTYPE (None , c_float , c_void_p )
159
159
160
160
161
+ # enum llama_log_level {
162
+ # LLAMA_LOG_LEVEL_ERROR = 2,
163
+ # LLAMA_LOG_LEVEL_WARN = 3,
164
+ # LLAMA_LOG_LEVEL_INFO = 4
165
+ # };
166
+ LLAMA_LOG_LEVEL_ERROR = c_int (2 )
167
+ LLAMA_LOG_LEVEL_WARN = c_int (3 )
168
+ LLAMA_LOG_LEVEL_INFO = c_int (4 )
169
+
170
+
171
+ # // Signature for logging events
172
+ # // Note that text includes the new line character at the end for most events.
173
+ # // If your logging mechanism cannot handle that, check if the last character is '\n' and strip it
174
+ # // if it exists.
175
+ # // It might not exist for progress report where '.' is output repeatedly.
176
+ # typedef void (*llama_log_callback)(enum llama_log_level level, const char * text, void * user_data);
177
+ llama_log_callback = ctypes .CFUNCTYPE (None , c_int , c_char_p , c_void_p )
178
+
179
+
161
180
# struct llama_context_params {
162
181
# uint32_t seed; // RNG seed, -1 for random
163
182
# int32_t n_ctx; // text context
@@ -351,6 +370,19 @@ class llama_timings(Structure):
351
370
]
352
371
353
372
373
+ # // Set callback for all future logging events.
374
+ # // If this is not called, or NULL is supplied, everything is output on stderr.
375
+ # LLAMA_API void llama_log_set(llama_log_callback log_callback, void * user_data);
376
+ def llama_log_set (
377
+ log_callback : "ctypes._FuncPointer" , user_data : c_void_p # type: ignore
378
+ ):
379
+ return _lib .llama_log_set (log_callback , user_data )
380
+
381
+
382
+ _lib .llama_log_set .argtypes = [llama_log_callback , c_void_p ]
383
+ _lib .llama_log_set .restype = None
384
+
385
+
354
386
# LLAMA_API int llama_max_devices();
355
387
def llama_max_devices () -> int :
356
388
return _lib .llama_max_devices ()
0 commit comments