Spaces:
Runtime error
Runtime error
Commit
·
137041a
1
Parent(s):
e0ec530
Improve UI
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ def predict(text,
|
|
| 26 |
max_length_tokens,
|
| 27 |
max_context_length_tokens,):
|
| 28 |
if text=="":
|
| 29 |
-
yield chatbot,history,"Empty
|
| 30 |
return
|
| 31 |
try:
|
| 32 |
model
|
|
@@ -36,7 +36,7 @@ def predict(text,
|
|
| 36 |
|
| 37 |
inputs = generate_prompt_with_history(text,history,tokenizer,max_length=max_context_length_tokens)
|
| 38 |
if inputs is None:
|
| 39 |
-
yield chatbot,history,"
|
| 40 |
return
|
| 41 |
else:
|
| 42 |
prompt,inputs=inputs
|
|
@@ -55,11 +55,11 @@ def predict(text,
|
|
| 55 |
x = x[:x.index("[|AI|]")].strip()
|
| 56 |
x = x.strip(" ")
|
| 57 |
a, b= [[y[0],convert_to_markdown(y[1])] for y in history]+[[text, convert_to_markdown(x)]],history + [[text,x]]
|
| 58 |
-
yield a, b, "Generating
|
| 59 |
if shared_state.interrupted:
|
| 60 |
shared_state.recover()
|
| 61 |
try:
|
| 62 |
-
yield a, b, "Stop Success"
|
| 63 |
return
|
| 64 |
except:
|
| 65 |
pass
|
|
@@ -68,7 +68,7 @@ def predict(text,
|
|
| 68 |
#print(x)
|
| 69 |
#print("="*80)
|
| 70 |
try:
|
| 71 |
-
yield a,b,"Generate Success"
|
| 72 |
except:
|
| 73 |
pass
|
| 74 |
|
|
@@ -81,7 +81,7 @@ def retry(
|
|
| 81 |
max_length_tokens,
|
| 82 |
max_context_length_tokens,
|
| 83 |
):
|
| 84 |
-
logging.info("Retry
|
| 85 |
if len(history) == 0:
|
| 86 |
yield chatbot, history, f"Empty context"
|
| 87 |
return
|
|
|
|
| 26 |
max_length_tokens,
|
| 27 |
max_context_length_tokens,):
|
| 28 |
if text=="":
|
| 29 |
+
yield chatbot,history,"Empty context."
|
| 30 |
return
|
| 31 |
try:
|
| 32 |
model
|
|
|
|
| 36 |
|
| 37 |
inputs = generate_prompt_with_history(text,history,tokenizer,max_length=max_context_length_tokens)
|
| 38 |
if inputs is None:
|
| 39 |
+
yield chatbot,history,"Input too long."
|
| 40 |
return
|
| 41 |
else:
|
| 42 |
prompt,inputs=inputs
|
|
|
|
| 55 |
x = x[:x.index("[|AI|]")].strip()
|
| 56 |
x = x.strip(" ")
|
| 57 |
a, b= [[y[0],convert_to_markdown(y[1])] for y in history]+[[text, convert_to_markdown(x)]],history + [[text,x]]
|
| 58 |
+
yield a, b, "Generating..."
|
| 59 |
if shared_state.interrupted:
|
| 60 |
shared_state.recover()
|
| 61 |
try:
|
| 62 |
+
yield a, b, "Stop: Success"
|
| 63 |
return
|
| 64 |
except:
|
| 65 |
pass
|
|
|
|
| 68 |
#print(x)
|
| 69 |
#print("="*80)
|
| 70 |
try:
|
| 71 |
+
yield a,b,"Generate: Success"
|
| 72 |
except:
|
| 73 |
pass
|
| 74 |
|
|
|
|
| 81 |
max_length_tokens,
|
| 82 |
max_context_length_tokens,
|
| 83 |
):
|
| 84 |
+
logging.info("Retry...")
|
| 85 |
if len(history) == 0:
|
| 86 |
yield chatbot, history, f"Empty context"
|
| 87 |
return
|