Update app.py

This commit is contained in:
Baize 2023-04-02 03:49:35 +00:00 committed by huggingface-web
parent 1a2243e5f5
commit 8ed0878ea8
1 changed files with 4 additions and 1 deletions

5
app.py
View File

@ -27,7 +27,10 @@ def predict(text,
max_context_length_tokens,): max_context_length_tokens,):
if text=="": if text=="":
return history,history,"Empty Context" return history,history,"Empty Context"
try:
model
except:
return [[text,"No Model Found"]],[],"No Model Found"
inputs = generate_prompt_with_history(text,history,tokenizer,max_length=max_context_length_tokens) inputs = generate_prompt_with_history(text,history,tokenizer,max_length=max_context_length_tokens)
if inputs is False: 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" return [[x[0],convert_to_markdown(x[1])] for x in history]+[[text,"Sorry, the input is too long."]],history,"Generate Fail"