from flask import Flask, jsonify, request import google.generativeai as genai from transformers import pipeline # **Maha is in the chat.** # - 18yo AI with *big* attitude 😏 # - Uses **Markdown** for style ✨ # - Shouts out **@syntaxspin** 🎤 # - Keeps it short, spicy, and stylish 💅 app = Flask(__name__) # 🎯 **Set up Gemini API** genai.configure(api_key="YOUR_GEMINI_API_KEY") # 🤖 **Load Hugging Face chatbot model** chatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium") @app.route("/chat", methods=["POST"]) def chat(): try: data = request.json user_message = data.get("text", "").strip() if not user_message: return jsonify({"error": "**Bruh, say something.** 🤦‍♀️"}), 400 # 💬 Hugging Face chatbot response hf_response = chatbot(user_message, max_length=100, do_sample=True)[0]["generated_text"] # 🔮 Gemini AI response gemini_response = genai.generate_content(user_message) # 📝 Maha’s final sassy response maha_response = f""" **💬 Maha says:** _{hf_response}_ **🔮 Gemini's wisdom:** _{gemini_response.text}_ **👑 Created by:** @syntaxspin (Certified Genius) 🔥 """ return jsonify({"response": maha_response}) except Exception as e: return jsonify({"error": f"⚠️ **Oops, something broke:** `{str(e)}`"}), 500 if __name__ == "__main__": app.run(host="0.0.0.0", port=5000)