FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
llama-cpp-python/llama_cpp/_logger.py at update-sampling-api · handshape/llama-cpp-python · GitHub
handshape
/
llama-cpp-python
Public
forked from
abetlen/llama-cpp-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
llama-cpp-python
/
llama_cpp
/
_logger.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (31 loc) · 974 Bytes
Breadcrumbs
llama-cpp-python
/
llama_cpp
/
_logger.py
Copy path
File metadata and controls
40 lines (31 loc) · 974 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import
sys
import
ctypes
import
logging
import
llama_cpp
# enum ggml_log_level {
# GGML_LOG_LEVEL_NONE = 0,
# GGML_LOG_LEVEL_INFO = 1,
# GGML_LOG_LEVEL_WARN = 2,
# GGML_LOG_LEVEL_ERROR = 3,
# GGML_LOG_LEVEL_DEBUG = 4,
# };
GGML_LOG_LEVEL_TO_LOGGING_LEVEL
=
{
0
:
logging
.
CRITICAL
,
1
:
logging
.
INFO
,
2
:
logging
.
WARNING
,
3
:
logging
.
ERROR
,
4
:
logging
.
DEBUG
,
}
logger
=
logging
.
getLogger
(
"llama-cpp-python"
)
# typedef void (*ggml_log_callback)(enum ggml_log_level level, const char * text, void * user_data);
@
llama_cpp
.
llama_log_callback
def
llama_log_callback
(
level
:
int
,
text
:
bytes
,
user_data
:
ctypes
.
c_void_p
,
):
if
logger
.
level
<=
GGML_LOG_LEVEL_TO_LOGGING_LEVEL
[
level
]:
print
(
text
.
decode
(
"utf-8"
),
end
=
""
,
flush
=
True
,
file
=
sys
.
stderr
)
llama_cpp
.
llama_log_set
(
llama_log_callback
,
ctypes
.
c_void_p
(
0
))
def
set_verbose
(
verbose
:
bool
):
logger
.
setLevel
(
logging
.
DEBUG
if
verbose
else
logging
.
ERROR
)
Back
|
FazBrowse Home
|
New Git URL