Update app.py
This commit is contained in:
parent
2736189eb4
commit
25a1a263ff
9
app.py
9
app.py
|
@ -26,14 +26,17 @@ def predict(text,
|
||||||
max_length_tokens,
|
max_length_tokens,
|
||||||
max_context_length_tokens,):
|
max_context_length_tokens,):
|
||||||
if text=="":
|
if text=="":
|
||||||
return history,history,"Empty Context"
|
yield chatbot,history,"Empty Context"
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
model
|
model
|
||||||
except:
|
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)
|
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"
|
yield chatbot+[[text,"Sorry, the input is too long."]],history,"Generate Fail"
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
prompt,inputs=inputs
|
prompt,inputs=inputs
|
||||||
begin_length = len(prompt)
|
begin_length = len(prompt)
|
||||||
|
|
Loading…
Reference in New Issue