Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,19 +5,29 @@ controller = SweetCommander()
|
|
5 |
|
6 |
title = "BlueDice - Practice Space"
|
7 |
char_name = "Alice"
|
8 |
-
chat_input = []
|
9 |
|
10 |
-
def predict(user_name, user_input,
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
|
17 |
gr.Interface(
|
18 |
fn = predict,
|
19 |
title = title,
|
20 |
-
inputs = [
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
).launch()
|
|
|
5 |
|
6 |
title = "BlueDice - Practice Space"
|
7 |
char_name = "Alice"
|
|
|
8 |
|
9 |
+
def predict(user_name, user_input, chat_history = []):
|
10 |
+
chat_input = []
|
11 |
+
for item in chat_history:
|
12 |
+
x, y = item
|
13 |
+
chat_input.append(f"{user_name}: {x}")
|
14 |
+
chat_input.append(f"{char_name}: {y}")
|
15 |
+
chat_input.append(f"{user_name}: {user_input}")
|
16 |
+
response = controller(char_name, user_name, "\n".join(chat_input))
|
17 |
+
chat_history.append((user_input, response))
|
18 |
+
return chat_history, chat_history
|
19 |
|
20 |
gr.Interface(
|
21 |
fn = predict,
|
22 |
title = title,
|
23 |
+
inputs = [
|
24 |
+
gr.Textbox(label = "User Name", placeholder = "Enter your name"),
|
25 |
+
gr.Textbox(label = "User Message", placeholder = "Enter your message"),
|
26 |
+
"state"
|
27 |
+
],
|
28 |
+
outputs = [
|
29 |
+
gr.Chatbot(label = "ChatBox"),
|
30 |
+
"state"
|
31 |
+
],
|
32 |
+
theme = "gstaff/sketch"
|
33 |
).launch()
|