From 9fa620e2e509ca69067c19319861ad516d7ecae1 Mon Sep 17 00:00:00 2001 From: wbbeyourself Date: Wed, 16 Sep 2026 17:38:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20eval=5Fllm.py=20Ctrl+C=20=E9=80=80?= =?UTF-8?q?=E5=87=BA=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eval_llm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eval_llm.py b/eval_llm.py index 9359ca8..8588898 100755 --- a/eval_llm.py +++ b/eval_llm.py @@ -64,7 +64,14 @@ def main(): input_mode = int(input('[0] 自动测试\n[1] 手动输入\n')) streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) - prompt_iter = prompts if input_mode == 0 else iter(lambda: input('💬: '), '') + def _next_prompt(): + try: + return input('💬: ') + except (EOFError, KeyboardInterrupt): + print() + return '' + + prompt_iter = prompts if input_mode == 0 else iter(_next_prompt, '') for prompt in prompt_iter: setup_seed(random.randint(0, 31415926)) if input_mode == 0: print(f'💬: {prompt}')