import streamlit as st
import os
from dotenv import load_dotenv
import google.generativeai as genai
# Load environment variables
load_dotenv()
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
# Validate API Key
if not GOOGLE_API_KEY:
st.error("Google Gemini API key not found. Please set GOOGLE_API_KEY in your .env file.")
st.stop()
# Configure Gemini
genai.configure(api_key=GOOGLE_API_KEY)
# Streamlit page setup
st.set_page_config(page_title="NeuraNexus: AI-Powered ML Assistant", page_icon="🧠", layout="wide")
# ==============================
# Custom CSS (include your full CSS here)
# ==============================
st.markdown("""
""", unsafe_allow_html=True)
# ==============================
# App UI
# ==============================
st.markdown('
NeuraNexus: AI-Powered ML Assistant
', unsafe_allow_html=True)
st.markdown('Describe your ML challenge, and let NeuraNexus craft an innovative solution.
', unsafe_allow_html=True)
# Input from user
user_prompt = st.text_area("Your ML Challenge", height=150, placeholder="Enter your machine learning challenge here...")
if 'response' not in st.session_state:
st.session_state.response = ""
# Generate button
if st.button("SYNTHESIZE"):
if not user_prompt.strip():
st.warning("Please describe your ML challenge first.")
else:
with st.spinner("NeuraNexus is thinking..."):
try:
model = genai.GenerativeModel("gemini-1.5-flash-8b")
chat = model.start_chat()
system_prompt = "You are NeuraNexus, an AI specialized in designing innovative and actionable ML strategies. Provide expert-level solutions to the given ML challenge."
full_prompt = f"{system_prompt}\n\nUser Problem:\n{user_prompt}"
response = chat.send_message(full_prompt)
st.session_state.response = response.text
st.success("Synthesis complete!")
except Exception as e:
st.session_state.response = f"❌ Error: {e}"
st.error("Gemini synthesis failed.")
# ==============================
# Show result
# ==============================
if st.session_state.response:
st.markdown("### NeuraNexus Synthesis Result")
st.markdown(f"""
{st.session_state.response}
""", unsafe_allow_html=True)
# Footer
st.markdown('By Theaimart
', unsafe_allow_html=True)
# Run wrapper
def main():
pass
if __name__ == "__main__":
main()