llama_ros: llama.cpp for ROS 2
Loading...
Searching...
No Matches
llama_utils Namespace Reference

Classes

struct  LlamaParams
 
class  Spinner
 

Typedefs

typedef void(* LogFunction) (const char *file, const char *function, int line, const char *text,...)
 Type definition for a logging function.
 

Enumerations

enum  LogLevel { ERROR = 0 , WARN , INFO , DEBUG }
 Enum representing different log levels for controlling log verbosity. More...
 

Functions

void declare_llama_params (const rclcpp_lifecycle::LifecycleNode::SharedPtr &node)
 
struct LlamaParams get_llama_params (const rclcpp_lifecycle::LifecycleNode::SharedPtr &node)
 
enum ggml_sched_priority parse_priority (std::string priority)
 
struct common_params_sampling parse_sampling_params (const llama_msgs::msg::SamplingConfig &sampling_config, int n_vocab)
 
const char * extract_filename (const char *path)
 Extracts the filename from a given file path.
 
void set_log_level (LogLevel log_level)
 Sets the log level for the logs.
 
void default_log_error (const char *file, const char *function, int line, const char *text,...)
 Default error logging function.
 
void default_log_warn (const char *file, const char *function, int line, const char *text,...)
 Default warning logging function.
 
void default_log_info (const char *file, const char *function, int line, const char *text,...)
 Default info logging function.
 
void default_log_debug (const char *file, const char *function, int line, const char *text,...)
 Default debug logging function.
 

Variables

LogFunction log_error = default_log_error
 Pointer to the error logging function.
 
LogFunction log_warn = default_log_warn
 Pointer to the warning logging function.
 
LogFunction log_info = default_log_info
 Pointer to the info logging function.
 
LogFunction log_debug = default_log_debug
 Pointer to the debug logging function.
 
LogLevel log_level = INFO
 The current log level for the application.
 

Typedef Documentation

◆ LogFunction

typedef void(* llama_utils::LogFunction) (const char *file, const char *function, int line, const char *text,...)

Type definition for a logging function.

This type represents a function pointer that takes a file name, function name, line number, log message, and a variable number of additional arguments for formatting the log message.

Parameters
fileThe name of the source file where the log function is called.
functionThe name of the function where the log function is called.
lineThe line number in the source file where the log function is called.
textThe format string for the log message, similar to printf.
...Additional arguments for the format string.

Enumeration Type Documentation

◆ LogLevel

Enum representing different log levels for controlling log verbosity.

This enum defines the severity levels of logs that can be used to control which log messages should be displayed. The levels are ordered from most severe to least severe. Only logs at or above the current log level will be shown.

Enumerator
ERROR 

Log level for error messages. Only critical errors should be logged.

WARN 

Log level for warning messages. Indicate potential issues that are not critical.

INFO 

Log level for informational messages. General runtime information about the system's state.

DEBUG 

Log level for debug messages. Used for detailed information, mainly for developers.

Function Documentation

◆ declare_llama_params()

void llama_utils::declare_llama_params ( const rclcpp_lifecycle::LifecycleNode::SharedPtr & node)

◆ default_log_debug()

void llama_utils::default_log_debug ( const char * file,
const char * function,
int line,
const char * text,
... )

Default debug logging function.

This function logs a debug message to stderr with the format: [DEBUG] [file:function:line] message.

Parameters
fileThe name of the source file where the log function is called.
functionThe name of the function where the log function is called.
lineThe line number in the source file where the log function is called.
textThe format string for the log message.
...Additional arguments for the format string.

◆ default_log_error()

void llama_utils::default_log_error ( const char * file,
const char * function,
int line,
const char * text,
... )

Default error logging function.

This function logs an error message to stderr with the format: [ERROR] [file:function:line] message.

Parameters
fileThe name of the source file where the log function is called.
functionThe name of the function where the log function is called.
lineThe line number in the source file where the log function is called.
textThe format string for the log message.
...Additional arguments for the format string.

◆ default_log_info()

void llama_utils::default_log_info ( const char * file,
const char * function,
int line,
const char * text,
... )

Default info logging function.

This function logs an informational message to stderr with the format: [INFO] [file:function:line] message.

Parameters
fileThe name of the source file where the log function is called.
functionThe name of the function where the log function is called.
lineThe line number in the source file where the log function is called.
textThe format string for the log message.
...Additional arguments for the format string.

◆ default_log_warn()

void llama_utils::default_log_warn ( const char * file,
const char * function,
int line,
const char * text,
... )

Default warning logging function.

This function logs a warning message to stderr with the format: [WARN] [file:function:line] message.

Parameters
fileThe name of the source file where the log function is called.
functionThe name of the function where the log function is called.
lineThe line number in the source file where the log function is called.
textThe format string for the log message.
...Additional arguments for the format string.

◆ extract_filename()

const char * llama_utils::extract_filename ( const char * path)
inline

Extracts the filename from a given file path.

This function takes a full path to a file and returns just the file name.

Parameters
pathThe full path to the file.
Returns
A pointer to the extracted filename.

◆ get_llama_params()

struct LlamaParams llama_utils::get_llama_params ( const rclcpp_lifecycle::LifecycleNode::SharedPtr & node)

◆ parse_priority()

enum ggml_sched_priority llama_utils::parse_priority ( std::string priority)

◆ parse_sampling_params()

struct common_params_sampling llama_utils::parse_sampling_params ( const llama_msgs::msg::SamplingConfig & sampling_config,
int n_vocab )

◆ set_log_level()

void llama_utils::set_log_level ( LogLevel log_level)

Sets the log level for the logs.

This function allows the user to specify the log level error, warning, info, or debug.

Parameters
log_levelLog level.

Variable Documentation

◆ log_debug

LogFunction llama_utils::log_debug = default_log_debug

Pointer to the debug logging function.

◆ log_error

LogFunction llama_utils::log_error = default_log_error

Pointer to the error logging function.

◆ log_info

LogFunction llama_utils::log_info = default_log_info

Pointer to the info logging function.

◆ log_level

LogLevel llama_utils::log_level = INFO

The current log level for the application.

This global variable holds the current log level, which determines the verbosity of the logs. Logs at or above this level will be displayed. The default level is set to INFO.

◆ log_warn

LogFunction llama_utils::log_warn = default_log_warn

Pointer to the warning logging function.