readme update

This commit is contained in:
martin legrand
2025-03-29 21:28:42 +01:00
5 changed files with 21 additions and 4 deletions
+17
View File
@@ -0,0 +1,17 @@
def timer_decorator(func):
"""
Decorator to measure the execution time of a function.
Usage:
@timer_decorator
def my_function():
# code to execute
"""
from time import time
def wrapper(*args, **kwargs):
start_time = time()
result = func(*args, **kwargs)
end_time = time()
print(f"\n{func.__name__} took {end_time - start_time:.2f} seconds to execute\n")
return result
return wrapper
+2
View File
@@ -1,6 +1,7 @@
from .generator import GeneratorLLM
from llama_cpp import Llama
from decorator import timer_decorator
class LlamacppLLM(GeneratorLLM):
@@ -11,6 +12,7 @@ class LlamacppLLM(GeneratorLLM):
super().__init__()
self.llm = None
@timer_decorator
def generate(self, history):
if self.llm is None:
self.logger.info(f"Loading {self.model}...")