Spaces:
Sleeping
Sleeping
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 | |
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" | |
).launch() |