Z3ta_Z / app.py
TejAndrewsACC's picture
Update app.py
1dbfd7d verified
raw
history blame
1.18 kB
import random
import gradio as gr
from gradio_client import Client
def random_response(message, history):
# Creating a persistent chat session with history for each user chat.
client = Client("TejAndrewsACC/Z3taACC-Plus")
# Make API call to chat with message, but do not pass history here
result = client.predict(
message=message,
max_tokens=2048,
temperature=0.7,
top_p=0.95,
api_name="/chat"
)
# Convert history to Gradio's expected format if not already
if history is None:
history = []
# Append the current message and response to history as dicts
history.append({"role": "user", "message": message})
history.append({"role": "assistant", "message": result})
# Return the response and updated history in the correct format
return result, history
# Set up Gradio chat interface
demo = gr.ChatInterface(
fn=random_response,
type="messages",
autofocus=False,
save_history=True,
show_progress="full",
flagging_mode="manual",
editable=True,
theme="TejAndrewsACC/zetaofficialthemeacc"
)
if __name__ == "__main__":
demo.launch()