import gradio as gr from huggingface_hub import InferenceClient client = InferenceClient("HuggingFaceH4/zephyr-7b-beta") def chat_response(message, history): messages = [] for user_msg, bot_msg in history: messages.append({"role": "user", "content": user_msg}) messages.append({"role": "assistant", "content": bot_msg}) messages.append({"role": "user", "content": message}) response = "" for msg in client.chat_completion(messages, max_tokens=1024, stream=True): response += msg.choices[0].delta.content or "" yield response # Yahan se error wali line hamesha ke liye hata di gayi hai demo = gr.ChatInterface( fn=chat_response, title="My Smart AI Chatbot", description="Main ek AI Assistant hoon. Mujhse kuch bhi puchiye!" ) demo.launch()