import os import gradio as gr import time from gradio_client import Client def get_response(query, history): history = str(history) client = Client("https://traversaal-fitx-ai.hf.space/", hf_token="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") result = client.predict( query, # str in 'query' Textbox component history, # str in 'history' Textbox component api_name="/predict" ) return result custom_css = """ """ def respond(message, chat_history): bot_message = get_response(message, chat_history) chat_history.append((message, bot_message)) time.sleep(0.5) return "", chat_history with gr.Blocks(theme=gr.themes.Soft()) as demo: chatbot = gr.Chatbot(title="Fitx AI Chatbot") msg = gr.Textbox(placeholder="I am your personal AI Trainer. Ask me a question") msg.submit(respond, [msg, chatbot], [msg, chatbot]) demo.launch(debug=True)