Update trans_web_demo.py

当设置prompt的时候跳过一轮
This commit is contained in:
Tianxiang Zhan 2024-06-08 16:39:07 +08:00 committed by GitHub
parent 76fff757b6
commit 8de4c76203
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -105,6 +105,8 @@ def predict(history, prompt, max_length, top_p, temperature):
if prompt:
messages.append({"role": "system", "content": prompt})
for idx, (user_msg, model_msg) in enumerate(history):
if prompt and idx == 0:
continue
if idx == len(history) - 1 and not model_msg:
messages.append({"role": "user", "content": user_msg})
break