Spaces:
Sleeping
Sleeping
File size: 3,283 Bytes
ab9f1fe 3ed0011 a6826d2 ab9f1fe 3ed0011 ab9f1fe a6826d2 3ed0011 a6826d2 ab9f1fe a6826d2 ab9f1fe a6826d2 ab9f1fe 3ed0011 a6826d2 3ed0011 a6826d2 3ed0011 ab9f1fe a6826d2 ab9f1fe 3ed0011 ab9f1fe a6826d2 ab9f1fe a6826d2 ab9f1fe a6826d2 3ed0011 a6826d2 ab9f1fe a6826d2 3ed0011 ab9f1fe 3ed0011 a6826d2 3ed0011 ab9f1fe a6826d2 ab9f1fe a6826d2 ab9f1fe a6826d2 ab9f1fe a6826d2 ab9f1fe 3ed0011 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
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("""
<style>
body {
background-color: #0F1C2E;
color: white;
font-family: 'Roboto', sans-serif;
}
h1 {
font-family: 'Orbitron', sans-serif;
color: #FF6B6B;
text-align: center;
font-size: 2.5em;
text-shadow: 0 0 10px rgba(255, 107, 107, 0.7);
}
.result-container {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(74, 144, 226, 0.2);
border-radius: 15px;
padding: 20px;
margin-top: 30px;
color: white;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
backdrop-filter: blur(10px);
}
.by-theaimart {
text-align: center;
font-size: 20px;
color: #50E3C2;
margin-top: 20px;
font-weight: bold;
}
</style>
""", unsafe_allow_html=True)
# ==============================
# App UI
# ==============================
st.markdown('<h1 class="glow">NeuraNexus: AI-Powered ML Assistant</h1>', unsafe_allow_html=True)
st.markdown('<h3 style="text-align:center;">Describe your ML challenge, and let NeuraNexus craft an innovative solution.</h3>', 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-pro")
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"""
<div class="result-container">
{st.session_state.response}
</div>
""", unsafe_allow_html=True)
# Footer
st.markdown('<p class="by-theaimart">By Theaimart</p>', unsafe_allow_html=True)
# Run wrapper
def main():
pass
if __name__ == "__main__":
main()
|