Update app.py

This commit is contained in:
Baize 2023-04-03 04:40:24 +00:00 committed by huggingface-web
parent 2736189eb4
commit 25a1a263ff
1 changed files with 6 additions and 3 deletions

9
app.py
View File

@ -26,14 +26,17 @@ def predict(text,
max_length_tokens,
max_context_length_tokens,):
if text=="":
return history,history,"Empty Context"
yield chatbot,history,"Empty Context"
return
try:
model
except:
return [[text,"No Model Found"]],[],"No Model Found"
yield [[text,"No Model Found"]],[],"No Model Found"
return
inputs = generate_prompt_with_history(text,history,tokenizer,max_length=max_context_length_tokens)
if inputs is False:
return [[x[0],convert_to_markdown(x[1])] for x in history]+[[text,"Sorry, the input is too long."]],history,"Generate Fail"
yield chatbot+[[text,"Sorry, the input is too long."]],history,"Generate Fail"
return
else:
prompt,inputs=inputs
begin_length = len(prompt)