This commit is contained in:
hailin 2025-07-08 11:33:10 +08:00
parent 6f1c422871
commit 5eff648d8b
1 changed files with 11 additions and 16 deletions

View File

@ -2,27 +2,23 @@ import gradio as gr
import subprocess import subprocess
def run_eval(inputs, native, other, outputs, api_url, api_token): def run_eval(inputs, native, other, outputs, api_url, api_token):
# 构造命令 timestamp = time.strftime("%Y%m%d-%H%M%S") # 生成当前时间戳作为 model 名
command = [ command = [
"evalscope", "perf", "evalscope", "perf",
"--parallel", "20",
"--model", "Qwen2.5-0.5B-Instruct",
"--url", api_url.strip(), "--url", api_url.strip(),
"--api", "openai", "--api", "openai",
"--token", api_token.strip(), "--model", timestamp, # ✅ 使用时间戳作为 --model
"--dataset", "random", "--dataset", "openqa",
"--min-tokens", "128", "--max-tokens", "1024",
"--max-tokens", "128", "--min-tokens", "1024",
"--prefix-length", "64", "--parallel", "1",
"--min-prompt-length", "1024", "--max-prompt-length", "15360",
"--max-prompt-length", "2048",
"--number", "100", "--number", "100",
"--tokenizer-path", "Qwen/Qwen2.5-0.5B-Instruct", "--api-key", api_token.strip(),
"--debug"
] ]
# 执行并流式输出 yield f"[Eval Started @ {timestamp}]\n"
yield "[Eval Started]\n"
try: try:
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1) process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1)
for line in process.stdout: for line in process.stdout:
@ -31,8 +27,7 @@ def run_eval(inputs, native, other, outputs, api_url, api_token):
process.wait() process.wait()
except Exception as e: except Exception as e:
yield f"[Error] {str(e)}\n" yield f"[Error] {str(e)}\n"
yield "[Eval Finished]" yield "[Eval Finished]\n"
def enforce_input_exclusive_and_toggle_fields(selected): def enforce_input_exclusive_and_toggle_fields(selected):
group1 = {"API Models", "Local Models"} group1 = {"API Models", "Local Models"}
group2 = {"Benchmarks", "Custom Datasets"} group2 = {"Benchmarks", "Custom Datasets"}