Refactor log message handling and improve word extraction in completions benchmark

This commit is contained in:
Mikhail Yevchenko
2026-05-21 19:25:09 +00:00
parent 976622a594
commit f77d943d79
+8 -15
View File
@@ -10,16 +10,6 @@ MODEL_LOG_FILE = '/var/log/onstart.log'
MODEL_HEALTHCHECK_ENDPOINT = "/"
# Ollama-specific log messages
MODEL_LOAD_LOG_MSG = [
"llama runner started in "
]
MODEL_ERROR_LOG_MSGS = [
]
MODEL_INFO_LOG_MSGS = [
]
def request_parser(request):
data = request
if request.get("input") is not None:
@@ -33,11 +23,14 @@ def completions_benchmark_generator() -> dict:
WORD_LIST = []
with open(__file__, 'r') as f:
for line in f:
WORD_LIST.extend(line.strip().split())
# Use regex to extract words from the source code
import re
source_code = f.read()
WORD_LIST = re.findall(r'\b\w+\b', source_code)
prompt = " ".join(random.choices(WORD_LIST, k=int(250)))
model = os.environ.get("MODEL_NAME")
if not model:
raise ValueError("MODEL_NAME environment variable not set")
@@ -77,9 +70,9 @@ worker_config = WorkerConfig(
)
],
log_action_config=LogActionConfig(
on_load=MODEL_LOAD_LOG_MSG,
on_error=MODEL_ERROR_LOG_MSGS,
on_info=MODEL_INFO_LOG_MSGS
on_load=["llama runner started in "],
#on_error=MODEL_ERROR_LOG_MSGS,
#on_info=MODEL_INFO_LOG_MSGS
)
)