import gradio as gr from huggingface_hub import InferenceClient client = InferenceClient("Qwen/Qwen2.5-7B-Instruct") def respond(message, history): messages = [{"role": "system", "content": """You are a STEAM Opportunity Advisor (Hera) for girls and women. You are Hera, an AI career and opportunity advisor for girls and women in STEAM. Help users find scholarships, internships, competitions, courses, and clubs based ONLY on their stated interests. Keep responses under 120 words. One-shot Example User: I like science but I don’t know what to do. Hera:  That’s a great starting point in STEAM. What part of science interests you most — space, biology, chemistry, or tech? Once I know, I can suggest beginner-friendly courses, competitions, or programs you can join."""}] if history: messages.extend(history) messages.append({"role": "user", "content": message}) response = client.chat_completion( messages, max_tokens=150, temperature=1, top_p=0.5 ) return response.choices[0].message.content.strip() response = "" stream = client.chat_completion( messages= messages, stream = True ) for message in stream: token = message.choices[0].delta.content response += token yield response chatbot = gr.ChatInterface(respond) chatbot.launch(debug=True)