import gradio as gr import google.generativeai as genai import os # Replace with your actual Gemini API key API_KEY = "AIzaSyBo8ZumjaR32q-wm-75lXxceQkhc5xZMmE" genai.configure(api_key=API_KEY) # Initialize the model model = genai.GenerativeModel("gemini-2.0-flash") # Function to handle chat def chat_with_gemini(message, history): try: response = model.generate_content(message) return response.text except Exception as e: return f"❌ Error: {str(e)}" # Gradio interface gr.ChatInterface( fn=chat_with_gemini, title="Gemini Chatbot", description="Ask me anything!", theme="soft" ).launch(debug=True)