API Reference

This page contains the complete API reference for LLMize.

Core Classes

OptimizationResult

class llmize.base.OptimizationResult(best_solution: Any, best_score: float, best_score_history: List[float], best_score_per_step: List[float], avg_score_per_step: List[float])[source]

A container class for storing and accessing the results of an optimization process.

This class provides a structured way to access all relevant information from an optimization run, including the best solution found, its score, and the complete optimization history.

Variables:
  • best_solution – The best solution found during optimization. Can be any type depending on the problem (string, list, tuple, etc.)

  • best_score – The score of the best solution (float)

  • best_score_history – Complete list of best scores at each step

  • best_score_per_step – List of best scores achieved in each batch

  • avg_score_per_step – List of average scores for each batch

Example

>>> result = optimizer.minimize(...)
>>> print(f"Best solution: {result.best_solution}")
>>> print(f"Best score: {result.best_score}")
>>> # Convert to dictionary for saving
>>> result_dict = result.to_dict()
__init__(best_solution: Any, best_score: float, best_score_history: List[float], best_score_per_step: List[float], avg_score_per_step: List[float])[source]
to_dict() Dict[str, Any][source]

Convert the result to a dictionary format.

Optimizer

class llmize.base.Optimizer(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Base class for all LLM-based optimizers in LLMize.

This class provides the common interface and functionality for all optimization methods. It handles configuration management, LLM initialization, and provides the standard maximize/minimize interface that all optimizers must implement.

All optimizer classes (OPRO, ADOPRO, HLMEA, HLMSA) inherit from this base class.

Variables:
  • problem_text (str) – Text description of the optimization problem

  • obj_func (callable) – Objective function to evaluate solutions

  • llm_model (str) – Name of the LLM model to use

  • api_key (str) – API key for the LLM service

Note

This class should not be used directly. Instead, use one of the specific optimizer implementations (OPRO, ADOPRO, HLMEA, HLMSA).

__init__(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Initialize the Optimizer with the general configuration.

Parameters:
  • problem_text (str, optional) – A natural language description of the optimization problem. This helps the LLM understand the context. If None, must be provided before optimization.

  • obj_func (callable, optional) – The objective function to optimize. Should accept a solution and return a numerical score. If None, must be provided before optimization.

  • llm_model (str, optional) – Name of the LLM model to use. If None, uses the default from configuration.

  • api_key (str, optional) – API key for the LLM service. If None, will look for environment variable or config setting.

maximize(init_samples=None, init_scores=None, num_steps=50, batch_size=5, temperature=1.0, callbacks=None, verbose=1, parallel_n_jobs=1)
minimize(init_samples=None, init_scores=None, num_steps=50, batch_size=5, temperature=1.0, callbacks=None, verbose=1, parallel_n_jobs=1)
get_configuration()[source]

Returns the general configuration of the optimizer.

meta_prompt(batch_size, example_pairs, optimization_type='maximize')[source]

Dummy function for meta_prompt. Should be overridden by subclasses.

Parameters: - batch_size (int): Number of new solutions to generate. - example_pairs (str): Example solutions and scores. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - prompt (str): A formatted prompt structure.

get_sample_prompt(batch_size=None, optimization_type='maximize', init_samples=None, init_scores=None)[source]

Generate a sample prompt for the language model based on the provided parameters.

Parameters: - batch_size (int): The number of new solutions to generate (default from config). - optimization_type (str): The type of optimization to perform, either “maximize” or “minimize” (default: “maximize”). - init_samples (list): A list of initial solutions (default: None). - init_scores (list): A list of initial scores corresponding to init_samples (default: None).

Returns: - str: The generated prompt as a string to be used for generating solutions from the language model.

get_sample_response(prompt)[source]

Generate a response from the language model using the provided prompt.

Parameters: - prompt (str): The prompt to be used for generating the response.

Returns: - str: The generated content as a string from the language model.

_generate_solutions(client, prompt, temperature, batch_size, verbose, max_retries=5, hp_parse=False)[source]

Generate solutions by retrying content generation until the solution array has the expected batch size.

Parameters:
  • client – The client instance to be passed to the content generation function.

  • llm_model – The language model to be used for generating content.

  • prompt – The prompt to send to the model.

  • temperature – The temperature parameter for content generation.

  • batch_size – Expected number of solutions.

  • verbose – Verbosity level for debug logging.

  • max_retries – Maximum number of retry attempts.

  • hp_parse – Whether to parse the hyperparameters from the response.

Returns:

A list of solutions that matches the expected batch_size.

Raises:

ValueError – If the expected number of solutions cannot be generated after max_retries.

_evaluate_solutions(solution_array, best_solution, optimization_type, verbose, best_score=None, parallel_n_jobs=None)[source]

Evaluate a list of solutions and update the best solution based on an objective function.

Parameters:
  • solution_array (list) – A list of solutions to evaluate.

  • optimization_type (str) – “maximize” or “minimize”.

  • verbose (int) – Verbosity level for logging.

  • obj_func (callable) – A function that takes a solution and returns its score.

  • best_score (float, optional) – The current best score. If not provided, it will be initialized based on the optimization_type.

  • parallel_n_jobs (int) – Number of CPU cores to use for parallel evaluation. If 1 (default), uses sequential processing. If >1, uses parallel processing with specified number of cores. If -1, uses all available cores.

Returns:

(best_score, best_solution, step_scores, best_step_score)

best_score (float): The updated best score after evaluating solutions. best_solution (any): The solution corresponding to the best score. step_scores (list): A list of scores for each solution in solution_array. best_step_score (float): The best score in the current batch.

Return type:

tuple

Raises:

ValueError – If optimization_type is not “maximize” or “minimize”.

_evaluate_single_solution(solution)[source]

Evaluate a single solution using the objective function.

Parameters:

solution – The solution to evaluate

Returns:

The score of the solution

Return type:

float

_initialize_callbacks(callbacks, temperature)[source]

Initialize wait counter and temperature for callbacks if early stopping or adaptive temperature is used.

Parameters: - callbacks (list): A list of callback functions. - temperature (float): The initial temperature for the LLM model.

Optimizers

OPRO

class llmize.methods.opro.OPRO(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Bases: Optimizer

No-index:

OPRO (Optimization by PROmpting) optimizer for numerical optimization using LLMs.

OPRO is the original approach that directly prompts LLMs to generate better solutions based on previous examples. It works by showing the LLM a history of solutions and their scores, then asking it to generate new solutions that improve upon the best ones.

This optimizer is best suited for: - Simple optimization problems with clear patterns - Problems where the relationship between solutions and scores is easily learnable - Quick prototyping and testing - Problems with relatively small search spaces

Example

>>> def sphere(x):
...     return sum(float(i)**2 for i in x)
>>>
>>> opro = OPRO(
...     problem_text="Minimize the sphere function sum(x_i^2)",
...     obj_func=sphere,
...     api_key="your-api-key"
... )
>>> result = opro.minimize(
...     init_samples=[["1", "1"], ["2", "2"]],
...     init_scores=[2, 8],
...     num_steps=10
... )

Note

This class inherits from Optimizer and uses the default configuration parameters unless overridden during initialization or optimization.

__init__(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Initialize the OPRO optimizer.

Parameters:
  • problem_text (str, optional) – Natural language description of the optimization problem. This should clearly state what needs to be optimized and any constraints.

  • obj_func (callable, optional) – Objective function that takes a solution and returns a numerical score. Higher scores indicate better solutions for maximization, lower scores for minimization.

  • llm_model (str, optional) – Name of the LLM model to use. If None, uses the default from configuration file.

  • api_key (str, optional) – API key for the LLM service. If None, will attempt to read from environment variables.

meta_prompt(batch_size, example_pairs, optimization_type='maximize')[source]

Generate a prompt for the LLM model to generate new solutions. Parameters: - batch_size (int): Number of new solutions to generate. - example_pairs (str): Example solutions and scores. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - text: A formatted prompt structure.

optimize(init_samples=None, init_scores=None, num_steps=None, batch_size=None, temperature=None, callbacks=None, verbose=1, optimization_type='maximize', parallel_n_jobs=None)[source]

Run the OPRO optimization algorithm.

Parameters: - init_samples (list): A list of initial solutions. - init_scores (list): A list of initial scores corresponding to init_samples. - num_steps (int): The number of optimization steps (default from config). - batch_size (int): The number of new solutions to generate at each step (default from config). - temperature (float): The temperature for the LLM model (default from config). - callbacks (list): A list of callback functions to be triggered at the end of each step. - optimization_type (str): “maximize” or “minimize” (default: “maximize”). - parallel_n_jobs (int): Number of parallel jobs for evaluation (default from config).

Returns: - results (OptimizationResult): An object containing the optimization results.

ADOPRO

class llmize.methods.adopro.ADOPRO(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Bases: Optimizer

No-index:

ADOPRO (Adaptive Optimization by PROmpting) optimizer for numerical optimization using LLMs.

ADOPRO is an enhanced version of OPRO that dynamically adjusts prompts based on optimization progress. It monitors the optimization trajectory and adapts the prompting strategy to escape local optima and improve convergence.

This optimizer is best suited for: - Complex optimization landscapes with multiple local optima - Problems where OPRO gets stuck or converges prematurely - Adaptive optimization strategies - Problems requiring dynamic exploration-exploitation balance

Example

>>> def rastrigin(x):
...     A = 10
...     n = len(x)
...     return A*n + sum(float(i)**2 - A*math.cos(2*math.pi*float(i)) for i in x)
>>>
>>> adopro = ADOPRO(
...     problem_text="Minimize the Rastrigin function (highly multimodal)",
...     obj_func=rastrigin,
...     api_key="your-api-key"
... )
>>> result = adopro.minimize(
...     init_samples=[["1", "1"], ["2", "2"], ["0", "0"]],
...     init_scores=[...],
...     num_steps=20
... )

Note

This class inherits from Optimizer and uses adaptive prompting strategies to improve upon the basic OPRO approach.

__init__(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Initialize the ADOPRO optimizer.

Parameters:
  • problem_text (str, optional) – Natural language description of the optimization problem. Should include information about the complexity and any known challenges (e.g., multimodality).

  • obj_func (callable, optional) – Objective function that takes a solution and returns a numerical score.

  • llm_model (str, optional) – Name of the LLM model to use. If None, uses the default from configuration file.

  • api_key (str, optional) – API key for the LLM service. If None, will attempt to read from environment variables.

meta_prompt(batch_size, example_pairs, optimization_type='maximize')[source]

Generate a prompt for the LLM model to generate new solutions. Parameters: - batch_size (int): Number of new solutions to generate. - example_pairs (str): Example solutions and scores. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - text: A formatted prompt structure.

optimize(init_samples=None, init_scores=None, num_steps=None, batch_size=None, temperature=None, callbacks=None, verbose=1, optimization_type='maximize', parallel_n_jobs=None)[source]

Run the ADOPRO optimization algorithm.

Parameters: - init_samples (list): A list of initial solutions. - init_scores (list): A list of initial scores corresponding to init_samples. - num_steps (int): The number of optimization steps (default: 50). - batch_size (int): The number of new solutions to generate at each step (default: 5). - temperature (float): The temperature for the LLM model (default: 1.0). - callbacks (list): A list of callback functions to be triggered at the end of each step. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - results (OptimizationResult): An object containing the optimization results.

HLMEA

class llmize.methods.hlmea.HLMEA(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Bases: Optimizer

No-index:

HLMEA (Hyper-heuristic LLM-driven Evolutionary Algorithm) optimizer for numerical optimization.

HLMEA combines evolutionary algorithm principles with LLM guidance to maintain solution diversity and avoid premature convergence. It uses hyper-heuristics to adaptively select evolutionary operators (selection, crossover, mutation) based on the optimization progress.

This optimizer is best suited for: - Combinatorial optimization problems (e.g., TSP, scheduling) - Large search spaces where diversity is crucial - Problems requiring exploration of multiple solution regions - Complex optimization landscapes with many local optima

Example

>>> def tsp_distance(tour):
...     # Calculate total distance for TSP tour
...     return total_distance
>>>
>>> hlmea = HLMEA(
...     problem_text="Solve the Traveling Salesman Problem - find shortest tour",
...     obj_func=tsp_distance,
...     api_key="your-api-key"
... )
>>> result = hlmea.minimize(
...     init_samples=[["A", "B", "C", "D"], ["A", "C", "B", "D"]],
...     init_scores=[100, 120],
...     num_steps=50,
...     batch_size=10
... )

Note

HLMEA uses sophisticated evolutionary strategies guided by LLM prompts to maintain diversity and avoid premature convergence.

__init__(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Initialize the HLMEA optimizer.

Parameters:
  • problem_text (str, optional) – Natural language description of the optimization problem. For combinatorial problems, specify the problem type and constraints.

  • obj_func (callable, optional) – Objective function that takes a solution and returns a numerical score.

  • llm_model (str, optional) – Name of the LLM model to use. If None, uses the default from configuration file.

  • api_key (str, optional) – API key for the LLM service. If None, will attempt to read from environment variables.

meta_prompt(batch_size, example_pairs, optimization_type='maximize', hp_text='The solutions below are generated randomly.')[source]

Generate a prompt for the LLM model to generate new solutions. Parameters: - batch_size (int): Number of new solutions to generate. - example_pairs (str): Example solutions and scores. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - text: A formatted prompt structure.

optimize(init_samples=None, init_scores=None, num_steps=None, batch_size=None, temperature=None, callbacks=None, verbose=1, optimization_type='maximize', parallel_n_jobs=None)[source]

Run the HLMEA optimization algorithm.

Parameters: - init_samples (list): A list of initial solutions. - init_scores (list): A list of initial scores corresponding to init_samples. - num_steps (int): The number of optimization steps (default: 50). - batch_size (int): The number of new solutions to generate at each step (default: 5). - temperature (float): The temperature for the LLM model (default: 1.0). - callbacks (list): A list of callback functions to be triggered at the end of each step. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - results (OptimizationResult): An object containing the optimization results.

HLMSA

class llmize.methods.hlmsa.HLMSA(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Bases: Optimizer

No-index:

HLMSA (Hyper-heuristic LLM-driven Simulated Annealing) optimizer for numerical optimization.

HLMSA combines simulated annealing principles with LLM optimization to provide controlled exploration of the solution space. It uses adaptive cooling rates and perturbation strategies to balance exploration and exploitation.

This optimizer is best suited for: - Problems with many local optima requiring careful exploration - Fine-tuning solutions where small improvements matter - Temperature-sensitive optimization problems - Problems where controlled convergence is important

Example

>>> def multimodal(x):
...     # Function with many local optima
...     return math.sin(5*x) + math.cos(3*x) + x**2
>>>
>>> hlmsa = HLMSA(
...     problem_text="Find global minimum of multimodal function",
...     obj_func=multimodal,
...     api_key="your-api-key"
... )
>>> result = hlmsa.minimize(
...     init_samples=[["0"], ["1"], ["-1"]],
...     init_scores=[...],
...     num_steps=30,
...     batch_size=5
... )

Note

HLMSA uses simulated annealing principles guided by LLM prompts to dynamically adjust cooling rates and perturbation strategies.

__init__(problem_text=None, obj_func=None, llm_model=None, api_key=None)[source]

Initialize the HLMSA optimizer.

Parameters:
  • problem_text (str, optional) – Natural language description of the optimization problem. For multimodal problems, mention the presence of local optima.

  • obj_func (callable, optional) – Objective function that takes a solution and returns a numerical score.

  • llm_model (str, optional) – Name of the LLM model to use. If None, uses the default from configuration file.

  • api_key (str, optional) – API key for the LLM service. If None, will attempt to read from environment variables.

meta_prompt(batch_size, example_pairs, optimization_type='maximize', hp_text='The solutions below are generated randomly.')[source]

Generate a prompt for the LLM model to generate new solutions using Simulated Annealing. Parameters: - batch_size (int): Number of new solutions to generate. - example_pairs (str): Example solutions and scores. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - text: A formatted prompt structure.

optimize(init_samples=None, init_scores=None, num_steps=None, batch_size=None, temperature=None, callbacks=None, verbose=1, optimization_type='maximize', parallel_n_jobs=None)[source]

Run the HLMSA optimization algorithm.

Parameters: - init_samples (list): A list of initial solutions. - init_scores (list): A list of initial scores corresponding to init_samples. - num_steps (int): The number of optimization steps (default: 50). - batch_size (int): The number of new solutions to generate at each step (default: 5). - temperature (float): The temperature for the LLM model (default: 1.0). - callbacks (list): A list of callback functions to be triggered at the end of each step. - optimization_type (str): “maximize” or “minimize” (default: “maximize”).

Returns: - results (OptimizationResult): An object containing the optimization results.

Callbacks

EarlyStopping

class llmize.callbacks.early_stopping.EarlyStopping(monitor='best_score', min_delta=0.01, patience=10, verbose=0)[source]
__init__(monitor='best_score', min_delta=0.01, patience=10, verbose=0)[source]

Early stopping callback to monitor a specified metric and stop if no improvement.

Parameters:
  • monitor – Metric to monitor (default: ‘best_score’).

  • min_delta – Minimum change to qualify as an improvement (default: 0.01).

  • patience – Number of steps with no improvement before stopping (default: 10).

  • verbose – Verbosity mode. 0 = no output, 1 = print message when early stopping triggers (default: 0).

on_step_end(step, logs=None)[source]

Check the stopping condition at the end of each step.

Parameters:
  • step – The current step number.

  • logs – Dictionary containing the logs (contains the metric to monitor).

AdaptTempOnPlateau

class llmize.callbacks.adapt_temp_on_plateau.AdaptTempOnPlateau(monitor='best_score', init_temperature=1.0, min_delta=0.0001, patience=10, factor=1.1, max_temperature=2.0, verbose=0)[source]
__init__(monitor='best_score', init_temperature=1.0, min_delta=0.0001, patience=10, factor=1.1, max_temperature=2.0, verbose=0)[source]

Adapt temperature on plateau callback to increase the temperature when the metric plateaus.

Parameters:
  • monitor – Metric to monitor (default: ‘best_score’).

  • min_delta – Minimum change to qualify as an improvement (default: 0.0001).

  • patience – Number of steps with no improvement before increasing temperature (default: 10).

  • factor – Factor by which the temperature will be increased (default: 1.2).

  • verbose – Verbosity mode. 0 = no output, 1 = print message when temperature is adapted (default: 0).

on_step_end(step, logs=None)[source]

Check the stopping condition at the end of each step and adapt temperature if necessary.

Parameters:
  • step – The current step number.

  • logs – Dictionary containing the logs (contains the metric to monitor).

OptimalScoreStopping

class llmize.callbacks.optimal_score_stopping.OptimalScoreStopping(optimal_score, tolerance=0.01)[source]
__init__(optimal_score, tolerance=0.01)[source]

Early stopping callback to monitor a specified metric and stop if no improvement.

Parameters:
  • monitor – Metric to monitor (default: ‘best_score’).

  • min_delta – Minimum change to qualify as an improvement (default: 0.01).

  • patience – Number of steps with no improvement before stopping (default: 10).

  • verbose – Verbosity mode. 0 = no output, 1 = print message when early stopping triggers (default: 0).

on_step_end(step, logs=None)[source]

Check the stopping condition at the end of each step.

Parameters:
  • step – The current step number.

  • logs – Dictionary containing the logs (contains the metric to monitor).

Configuration

Config

class llmize.config.Config(config_file: str | None = None)[source]

Configuration class for llmize settings.

__init__(config_file: str | None = None)[source]

Initialize configuration.

Parameters:

config_file – Path to config file. If None, looks for default locations.

_load_config(config_file: str | None = None)[source]

Load configuration from file.

_set_defaults()[source]

Set default configuration values.

get(key: str, default=None)[source]

Get configuration value using dot notation.

Parameters:
  • key – Configuration key (e.g., ‘llm.default_model’)

  • default – Default value if key not found

Returns:

Configuration value

property default_model: str

Get the default LLM model.

property temperature: float

Get the default temperature.

property max_retries: int

Get the default max retries.

property retry_delay: int

Get the default retry delay.

property default_num_steps: int

Get the default number of optimization steps.

property default_batch_size: int

Get the default batch size.

property parallel_n_jobs: int

Get the default number of parallel jobs.

get_api_key(provider: str) str | None[source]

Get API key for a specific provider.

get_base_url(provider: str) str | None[source]

Get base URL for a specific provider.

Utility Modules

LLM Interface

llmize.llm.llm_call.generate_content(client, model, prompt, temperature=None, max_retries=None, retry_delay=None)[source]

Generate content using the specified language model.

This function delegates the content generation to either the Gemini or Hugging Face model based on the provided model name.

Parameters: - client: The API client used to interact with the language model. - model (str): The name of the language model to use. - prompt (str): The textual prompt to generate content from. - temperature (float, optional): Controls the creativity of the responses (default from config). - max_retries (int, optional): Maximum number of retry attempts in case of rate-limiting (default from config). - retry_delay (int, optional): Delay in seconds between retry attempts (default from config).

Returns: - str: The generated content as a string, or None if the request was unsuccessful after retries.

llmize.llm.llm_call.generate_content_gemini(client, model, prompt, temperature, max_retries=10, retry_delay=5)[source]
llmize.llm.llm_call.generate_content_huggingface(client, model, prompt, temperature, max_retries=10, retry_delay=5)[source]
llmize.llm.llm_call.generate_content_openrouter(client, model, prompt, temperature, max_retries=10, retry_delay=5)[source]

Generate content using OpenRouter API.

llmize.llm.llm_call.generate_content_openai(client, model, prompt, temperature, max_retries=10, retry_delay=5)[source]
llmize.llm.llm_init.initialize_llm(llm_model, api_key)[source]
llmize.llm.llm_init.initialize_gemini(api_key)[source]
llmize.llm.llm_init.initialize_huggingface(api_key)[source]
llmize.llm.llm_init.initialize_openrouter(api_key)[source]

Initialize OpenRouter client with custom API format.

llmize.llm.llm_init.initialize_openai(api_key)[source]

Parsing Utilities

llmize.utils.parsing.parse_response(response_text, hp_parse=False)[source]

Parses the generated response into a list of lists. Returns None if parsing fails.

llmize.utils.parsing.parse_pairs(samples, scores)[source]
llmize.utils.parsing.parse_score(text)[source]
llmize.utils.truncate.truncate_pairs(pairs, nmax=10, optimization_type='maximize', method='mixed')[source]

Truncate a list of pairs to a maximum number of solutions.

Parameters: - pairs (str): A string of example solutions and scores. - nmax (int): The maximum number of solutions to keep. Default is 10. - optimization_type (str): “maximize” or “minimize”. Default is “maximize”. - method (str): “best”, “random”, or “mixed”. Default is “mixed”.

Returns: - truncated_pairs (str): A string of the truncated list of pairs.

Notes: - The “best” method keeps the top nmax solutions based on the scores. - The “random” method randomly selects nmax solutions from the list. - The “mixed” method keeps the top nmax//2 solutions and randomly selects nmax-nmax//2 solutions from the remaining list.

Logging

class llmize.utils.logger.ColoredFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]
formatTime(record, datefmt=None)[source]

Return the creation time of the specified LogRecord as formatted text.

This method should be called from format() by a formatter which wants to make use of a formatted time. This method can be overridden in formatters to provide for any specific requirement, but the basic behaviour is as follows: if datefmt (a string) is specified, it is used with time.strftime() to format the creation time of the record. Otherwise, an ISO8601-like (or RFC 3339-like) format is used. The resulting string is returned. This function uses a user-configurable function to convert the creation time to a tuple. By default, time.localtime() is used; to change this for a particular formatter instance, set the ‘converter’ attribute to a function with the same signature as time.localtime() or time.gmtime(). To change it for all formatters, for example if you want all logging times to be shown in GMT, set the ‘converter’ attribute in the Formatter class.

format_with_time(record)[source]
format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

llmize.utils.logger.log_debug(message)[source]
llmize.utils.logger.log_info(message)[source]
llmize.utils.logger.log_warning(message)[source]
llmize.utils.logger.log_error(message)[source]
llmize.utils.logger.log_critical(message)[source]
llmize.utils.logger.set_log_level(level)[source]

Set the logging level dynamically.

Parameters:

level – Logging level (e.g., logging.DEBUG, logging.INFO, logging.WARNING)

Submodules