import gradio as gr from huggingface_hub import InferenceClient client = InferenceClient("Qwen/Qwen2.5-7B-Instruct") def random_response(message,history): messages= [{"role": "system", "content": "You are a friendly chatbot."}] if history: messages.extend(history) message.append({"role":"user", "content": messages}) response = client.chat_completion( message, max_tokens=100 ) return response.choices[0].message.content.strip() chatbot = gr.ChatInterface(random_response, title = "Magic 8 Ball Chatbot") chatbot.launch()