File size: 943 Bytes
39f927e
 
 
 
 
 
 
 
c8b7372
 
 
 
 
 
 
 
 
c312567
39f927e
6a37e43
39f927e
 
32b0362
 
 
 
 
 
 
 
 
 
6a37e43
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from handler import SweetCommander
import gradio as gr

controller = SweetCommander()

title = "BlueDice - Practice Space"
char_name = "Alice"

def predict(user_name, user_input, chat_history = []):
    chat_input = []
    for item in chat_history:
        x, y = item
        chat_input.append(f"{user_name}: {x}")
        chat_input.append(f"{char_name}: {y}")
    chat_input.append(f"{user_name}: {user_input}")
    response = controller(char_name, user_name, "\n".join(chat_input))
    chat_history.append((user_input, response))
    return chat_history, chat_history

app = gr.Interface(
    fn = predict,
    title = title,
    inputs = [
        gr.Textbox(label = "User Name", placeholder = "Enter your name"),
        gr.Textbox(label = "User Message", placeholder = "Enter your message"),
        "state"
    ],
    outputs = [
        gr.Chatbot(label = "ChatBox"),
        "state"
    ],
    theme = "gstaff/sketch"
)

app.launch()