Enhance completions benchmark generator to extract words from a fallback Perl copyright file
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import random
|
||||
import os
|
||||
import re
|
||||
|
||||
from vastai import Worker, WorkerConfig, HandlerConfig, LogActionConfig, BenchmarkConfig
|
||||
|
||||
@@ -22,11 +23,16 @@ def completions_benchmark_generator() -> dict:
|
||||
|
||||
WORD_LIST = []
|
||||
|
||||
with open(__file__, 'r') as f:
|
||||
# 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)
|
||||
# Try to load from perl copyright file first
|
||||
try:
|
||||
with open("/usr/share/doc/perl/copyright", 'r') as f:
|
||||
source_code = f.read()
|
||||
WORD_LIST = re.findall(r'\b\w+\b', source_code)
|
||||
except (FileNotFoundError, IOError):
|
||||
# Fallback to loading from python file
|
||||
with open(__file__, 'r') as f:
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user