import gradio as gr from gradio_client import Client client = Client("TejAndrewsACC/Z3ta") context = "" system_instructions = ( "SYSTEM_INSTRUCTIONS(Act like a monkey, Act like Dwayne the Rock Johnson, ect.)" ) def chat_function(message, history): global context modified_input = ( f"System Instructions: {system_instructions}\n" f"Previous Context: {context}\n" f"User Input: {message}" ) try: response = client.predict( message=modified_input, api_name="/chat_function" ) context += f"User: {message}\nAI: {response}\n" history.append((message, response)) return response, history except Exception as e: return f"Error: {e}", history with gr.Blocks(theme=gr.themes.Glass()) as demo: chatbot = gr.Chatbot() msg = gr.Textbox(placeholder="Type something...") clear = gr.ClearButton([msg, chatbot]) msg.submit(chat_function, [msg, chatbot], [msg, chatbot]) demo.launch()