Update app.py

This commit is contained in:
Baize 2023-04-05 01:40:27 +00:00 committed by huggingface-web
parent 3d2cf1ed18
commit db8c43fa76
1 changed files with 4 additions and 1 deletions

5
app.py
View File

@ -4,6 +4,7 @@ import logging
import sys import sys
import gradio as gr import gradio as gr
import torch import torch
import gc
from app_modules.utils import * from app_modules.utils import *
from app_modules.presets import * from app_modules.presets import *
from app_modules.overwrites import * from app_modules.overwrites import *
@ -53,7 +54,7 @@ def predict(text,
x = x[:x.index("[|Human|]")].strip() x = x[:x.index("[|Human|]")].strip()
if "[|AI|]" in x: if "[|AI|]" in x:
x = x[:x.index("[|AI|]")].strip() x = x[:x.index("[|AI|]")].strip()
x = x.strip(" ") x = x.strip()
a, b= [[y[0],convert_to_markdown(y[1])] for y in history]+[[text, convert_to_markdown(x)]],history + [[text,x]] a, b= [[y[0],convert_to_markdown(y[1])] for y in history]+[[text, convert_to_markdown(x)]],history + [[text,x]]
yield a, b, "Generating..." yield a, b, "Generating..."
if shared_state.interrupted: if shared_state.interrupted:
@ -63,6 +64,8 @@ def predict(text,
return return
except: except:
pass pass
del input_ids
gc.collect()
torch.cuda.empty_cache() torch.cuda.empty_cache()
#print(text) #print(text)
#print(x) #print(x)