This commit is contained in:
hailin 2025-07-08 12:48:57 +08:00
parent d98c5ae851
commit ff7ce8c4f0
1 changed files with 13 additions and 7 deletions

View File

@ -3,13 +3,12 @@ import gradio as gr
import subprocess
def run_eval(inputs, native, other, outputs, api_url, api_token):
timestamp = time.strftime("%Y%m%d-%H%M%S") # 生成当前时间戳作为 model 名
timestamp = time.strftime("%Y%m%d-%H%M%S")
command = [
"evalscope", "perf",
"--url", api_url.strip(),
"--api", "openai",
"--model", timestamp, # ✅ 使用时间戳作为 --model
"--model", timestamp,
"--dataset", "openqa",
"--max-tokens", "1024",
"--min-tokens", "1024",
@ -19,16 +18,23 @@ def run_eval(inputs, native, other, outputs, api_url, api_token):
"--api-key", api_token.strip(),
]
yield f"[Eval Started @ {timestamp}]\n"
full_output = f"[Eval Started @ {timestamp}]\n"
yield full_output
try:
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1)
for line in process.stdout:
yield line
full_output += line
yield full_output # ✅ 每次 yield 累积的完整内容
process.stdout.close()
process.wait()
except Exception as e:
yield f"[Error] {str(e)}\n"
yield "[Eval Finished]\n"
full_output += f"[Error] {str(e)}\n"
yield full_output
full_output += "[Eval Finished]\n"
yield full_output
def enforce_input_exclusive_and_toggle_fields(selected):
group1 = {"API Models", "Local Models"}
group2 = {"Benchmarks", "Custom Datasets"}