Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -45,6 +45,7 @@ HEADERS = {
|
|
45 |
|
46 |
|
47 |
MAX_SEC = 30
|
|
|
48 |
|
49 |
tokenizer = AutoTokenizer.from_pretrained("MediaTek-Research/Breeze-7B-Instruct-v0_1")
|
50 |
|
@@ -161,6 +162,9 @@ with gr.Blocks() as demo:
|
|
161 |
message = tokenizer.apply_chat_template(chat_data, tokenize=False)
|
162 |
message = message[3:] # remove SOT token
|
163 |
|
|
|
|
|
|
|
164 |
response = ''
|
165 |
if refusal_condition(history[-1][0]):
|
166 |
history = [['[安全拒答啟動]', '[安全拒答啟動] 請清除再開啟對話']]
|
|
|
45 |
|
46 |
|
47 |
MAX_SEC = 30
|
48 |
+
MAX_INPUT_LENGTH = 5000
|
49 |
|
50 |
tokenizer = AutoTokenizer.from_pretrained("MediaTek-Research/Breeze-7B-Instruct-v0_1")
|
51 |
|
|
|
162 |
message = tokenizer.apply_chat_template(chat_data, tokenize=False)
|
163 |
message = message[3:] # remove SOT token
|
164 |
|
165 |
+
if len(message) > MAX_INPUT_LENGTH:
|
166 |
+
raise Exception()
|
167 |
+
|
168 |
response = ''
|
169 |
if refusal_condition(history[-1][0]):
|
170 |
history = [['[安全拒答啟動]', '[安全拒答啟動] 請清除再開啟對話']]
|