TejAndrewsACC's picture
Update app.py
394c485 verified
import gradio as gr
from gradio_client import Client
mark_client = Client("TejAndrewsACC/ACC-Emulect-Base")
z3taz_client = Client("TejAndrewsACC/Z3taZ2025ACC")
def chat(user_message, history):
if history is None:
history = []
history.append(("User", user_message))
context = "\n".join([f"{speaker}: {message}" for speaker, message in history])
try:
mark_response = mark_client.predict(message=context, api_name="/chat")
except Exception:
mark_response = ""
try:
z3taz_response = z3taz_client.predict(
message=context,
param_2=2048,
param_3=0.7,
param_4=0.95,
api_name="/chat"
)
except Exception:
z3taz_response = ""
if mark_response.strip():
history.append(("Mark", mark_response))
if z3taz_response.strip():
history.append(("Z3ta-Z", z3taz_response))
display_history = [(f"{speaker}:", message) for speaker, message in history]
return display_history, "", history
def clear_chat():
return [], "", []
with gr.Blocks(theme="TejAndrewsACC/ACC") as demo:
gr.Markdown("<h1>ACC Group Chat</h1>")
chatbot = gr.Chatbot()
state = gr.State([])
user_input = gr.Textbox(placeholder="Type your message here...")
send_button = gr.Button("Send")
clear_button = gr.Button("Clear")
send_button.click(chat, inputs=[user_input, state], outputs=[chatbot, user_input, state])
clear_button.click(clear_chat, outputs=[chatbot, user_input, state])
if __name__ == "__main__":
demo.launch()