#genai.configure(api_key="AIzaSyB2FrTywdRUmHXICxRPYTN_TznajASTKDY") import streamlit as st import google.generativeai as genai # Configure the API key for Gemini AI genai.configure(api_key="AIzaSyD8tAz466UNCkLl83WBT05imim-JYL5Gr4") # AIzaSyB2FrTywdRUmHXICxRPYTN_TznajASTKDY model = genai.GenerativeModel("gemini-1.5-flash") # Streamlit App layout st.title("AI-Powered Python Code Assistant") st.markdown("This assistant can help you with code suggestions, debugging, and reusable snippets using Gemini AI.") # Sidebar st.sidebar.header("Select Feature") feature = st.sidebar.selectbox( "Choose what you need help with:", ["Code Suggestions", "Code Debugging", "Reusable Code Snippets", "General Code Query"] ) # Input box for user to type code or query user_input = st.text_area("Enter your Python code or query here:") # Button to trigger the AI response if st.button("Get AI Suggestions"): # Generate response based on selected feature if feature == "Code Suggestions": prompt = f"Suggest code completion for the following Python code:\n{user_input}" elif feature == "Code Debugging": prompt = f"Find and fix the bugs in the following Python code:\n{user_input}" elif feature == "Reusable Code Snippets": prompt = f"Provide reusable Python code snippets related to: {user_input}" else: prompt = f"Provide an explanation or advice on this Python code/query:\n{user_input}" # Get response from Gemini AI model response = model.generate_content(prompt) # Display AI's response in the app st.subheader("AI's Response:") st.code(response.text, language="python") # Optionally, you can add a footer or additional features here st.markdown("---") st.markdown("Powered by **Streamlit** and **Google Gemini AI**")