CoolFace
Apppublic

THEAIMART/machinelearningassistant

sourceHugging Faceupdated 1y agoView on Hugging Face
1likes
app.py112 linesDownload Raw Back to root
1import streamlit as st2import os3from dotenv import load_dotenv4import google.generativeai as genai5 6# Load environment variables7load_dotenv()8GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")9 10# Validate API Key11if not GOOGLE_API_KEY:12    st.error("Google Gemini API key not found. Please set GOOGLE_API_KEY in your .env file.")13    st.stop()14 15# Configure Gemini16genai.configure(api_key=GOOGLE_API_KEY)17 18# Streamlit page setup19st.set_page_config(page_title="NeuraNexus: AI-Powered ML Assistant", page_icon="🧠", layout="wide")20 21# ==============================22# Custom CSS (include your full CSS here)23# ==============================24st.markdown("""25<style>26body {27    background-color: #0F1C2E;28    color: white;29    font-family: 'Roboto', sans-serif;30}31h1 {32    font-family: 'Orbitron', sans-serif;33    color: #FF6B6B;34    text-align: center;35    font-size: 2.5em;36    text-shadow: 0 0 10px rgba(255, 107, 107, 0.7);37}38.result-container {39    background: rgba(255, 255, 255, 0.05);40    border: 1px solid rgba(74, 144, 226, 0.2);41    border-radius: 15px;42    padding: 20px;43    margin-top: 30px;44    color: white;45    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);46    backdrop-filter: blur(10px);47}48.by-theaimart {49    text-align: center;50    font-size: 20px;51    color: #50E3C2;52    margin-top: 20px;53    font-weight: bold;54}55</style>56""", unsafe_allow_html=True)57 58# ==============================59# App UI60# ==============================61st.markdown('<h1 class="glow">NeuraNexus: AI-Powered ML Assistant</h1>', unsafe_allow_html=True)62st.markdown('<h3 style="text-align:center;">Describe your ML challenge, and let NeuraNexus craft an innovative solution.</h3>', unsafe_allow_html=True)63 64# Input from user65user_prompt = st.text_area("Your ML Challenge", height=150, placeholder="Enter your machine learning challenge here...")66 67if 'response' not in st.session_state:68    st.session_state.response = ""69 70# Generate button71if st.button("SYNTHESIZE"):72    if not user_prompt.strip():73        st.warning("Please describe your ML challenge first.")74    else:75        with st.spinner("NeuraNexus is thinking..."):76            try:77                model = genai.GenerativeModel("gemini-1.5-flash-8b")78                chat = model.start_chat()79 80                system_prompt = "You are NeuraNexus, an AI specialized in designing innovative and actionable ML strategies. Provide expert-level solutions to the given ML challenge."81 82                full_prompt = f"{system_prompt}\n\nUser Problem:\n{user_prompt}"83 84                response = chat.send_message(full_prompt)85                st.session_state.response = response.text86                st.success("Synthesis complete!")87 88            except Exception as e:89                st.session_state.response = f"❌ Error: {e}"90                st.error("Gemini synthesis failed.")91 92# ==============================93# Show result94# ==============================95if st.session_state.response:96    st.markdown("### NeuraNexus Synthesis Result")97    st.markdown(f"""98    <div class="result-container">99        {st.session_state.response}100    </div>101    """, unsafe_allow_html=True)102 103# Footer104st.markdown('<p class="by-theaimart">By Theaimart</p>', unsafe_allow_html=True)105 106# Run wrapper107def main():108    pass109 110if __name__ == "__main__":111    main()112