Refactor log message handling and improve word extraction in completions benchmark
This commit is contained in:
@@ -10,16 +10,6 @@ MODEL_LOG_FILE = '/var/log/onstart.log'
|
|||||||
MODEL_HEALTHCHECK_ENDPOINT = "/"
|
MODEL_HEALTHCHECK_ENDPOINT = "/"
|
||||||
|
|
||||||
# Ollama-specific log messages
|
# Ollama-specific log messages
|
||||||
MODEL_LOAD_LOG_MSG = [
|
|
||||||
"llama runner started in "
|
|
||||||
]
|
|
||||||
|
|
||||||
MODEL_ERROR_LOG_MSGS = [
|
|
||||||
]
|
|
||||||
|
|
||||||
MODEL_INFO_LOG_MSGS = [
|
|
||||||
]
|
|
||||||
|
|
||||||
def request_parser(request):
|
def request_parser(request):
|
||||||
data = request
|
data = request
|
||||||
if request.get("input") is not None:
|
if request.get("input") is not None:
|
||||||
@@ -33,11 +23,14 @@ def completions_benchmark_generator() -> dict:
|
|||||||
WORD_LIST = []
|
WORD_LIST = []
|
||||||
|
|
||||||
with open(__file__, 'r') as f:
|
with open(__file__, 'r') as f:
|
||||||
for line in f:
|
# Use regex to extract words from the source code
|
||||||
WORD_LIST.extend(line.strip().split())
|
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)))
|
prompt = " ".join(random.choices(WORD_LIST, k=int(250)))
|
||||||
model = os.environ.get("MODEL_NAME")
|
model = os.environ.get("MODEL_NAME")
|
||||||
|
|
||||||
if not model:
|
if not model:
|
||||||
raise ValueError("MODEL_NAME environment variable not set")
|
raise ValueError("MODEL_NAME environment variable not set")
|
||||||
|
|
||||||
@@ -77,9 +70,9 @@ worker_config = WorkerConfig(
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
log_action_config=LogActionConfig(
|
log_action_config=LogActionConfig(
|
||||||
on_load=MODEL_LOAD_LOG_MSG,
|
on_load=["llama runner started in "],
|
||||||
on_error=MODEL_ERROR_LOG_MSGS,
|
#on_error=MODEL_ERROR_LOG_MSGS,
|
||||||
on_info=MODEL_INFO_LOG_MSGS
|
#on_info=MODEL_INFO_LOG_MSGS
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user