Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,23 +10,18 @@ MAX_TURNS = 20
|
|
10 |
MAX_BOXES = MAX_TURNS * 2
|
11 |
|
12 |
|
13 |
-
def predict(input, max_length, top_p, temperature, history=None
|
14 |
-
if
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
updates = []
|
24 |
-
|
25 |
-
updates.append(gr.update(visible=True, value=query))
|
26 |
-
updates.append(gr.update(visible=True, value=response))
|
27 |
-
if len(updates) < MAX_BOXES:
|
28 |
-
updates = updates + [gr.Textbox.update(visible=False)] * (MAX_BOXES - len(updates))
|
29 |
-
yield [history] + updates
|
30 |
|
31 |
|
32 |
with gr.Blocks() as demo:
|
|
|
10 |
MAX_BOXES = MAX_TURNS * 2
|
11 |
|
12 |
|
13 |
+
def predict(input, max_length, top_p, temperature, history=None):
|
14 |
+
if history is None:
|
15 |
+
history = []
|
16 |
+
response, history = model.chat(tokenizer, input, history, max_length=max_length, top_p=top_p,
|
17 |
+
temperature=temperature)
|
18 |
+
updates = []
|
19 |
+
for query, response in history:
|
20 |
+
updates.append(gr.update(visible=True, value="用户:" + query))
|
21 |
+
updates.append(gr.update(visible=True, value="ChatGLM-6B:" + response))
|
22 |
+
if len(updates) < MAX_BOXES:
|
23 |
+
updates = updates + [gr.Textbox.update(visible=False)] * (MAX_BOXES - len(updates))
|
24 |
+
return [history] + updates
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
27 |
with gr.Blocks() as demo:
|