BlueDice commited on
Commit
a5c6b42
·
1 Parent(s): ef4ab24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
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, history = []):
11
- history.append(f"{user_name}: {user_input}")
12
- response = controller(char_name, user_name, "\n".join(history))
13
- history.append(f"{char_name}: {response}")
14
- chat_input.append((user_input, response))
15
- return chat_input, history
 
 
 
 
16
 
17
  gr.Interface(
18
  fn = predict,
19
  title = title,
20
- inputs = ["text", "text", "state"],
21
- outputs = ["chatbot", "state"],
22
- theme = "gradio/seafoam"
 
 
 
 
 
 
 
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()