Spaces:
Sleeping
Sleeping
File size: 5,430 Bytes
ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 ab9f1fe 3ed0011 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
import streamlit as st
from dotenv import load_dotenv
import os
from crewai import Agent, Task, Crew
from langchain_google_genai import ChatGoogleGenerativeAI
# Load environment variables
load_dotenv()
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
# API key validation
if not GOOGLE_API_KEY:
st.error("Google Gemini API key not found. Please set it in the .env file.")
st.stop()
# Streamlit config
st.set_page_config(page_title="NeuraNexus: AI-Powered ML Assistant", page_icon="🧠", layout="wide")
# ==========================
# CSS & Animation
# ==========================
st.markdown("""
<style>
/* (Only showing part of the long CSS here to avoid repetition. Replace with your full custom CSS/JS from the previous version) */
body {
background-color: #0F1C2E;
color: #FFFFFF;
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: #FFFFFF;
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>
<!-- Optional neural animation background -->
<div class="neural-network" id="neuralNetwork"></div>
<script>
function createNeuralNetwork() {
const container = document.getElementById('neuralNetwork');
const numNeurons = 20;
const numSynapses = 30;
for (let i = 0; i < numNeurons; i++) {
const neuron = document.createElement('div');
neuron.classList.add('neuron');
neuron.style.left = `${Math.random() * 100}%`;
neuron.style.top = `${Math.random() * 100}%`;
neuron.style.width = `${Math.random() * 10 + 5}px`;
neuron.style.height = neuron.style.width;
container.appendChild(neuron);
}
for (let i = 0; i < numSynapses; i++) {
const synapse = document.createElement('div');
synapse.classList.add('synapse');
synapse.style.left = `${Math.random() * 100}%`;
synapse.style.top = `${Math.random() * 100}%`;
synapse.style.width = `${Math.random() * 200 + 50}px`;
synapse.style.transform = `rotate(${Math.random() * 360}deg)`;
container.appendChild(synapse);
}
}
document.addEventListener('DOMContentLoaded', createNeuralNetwork);
</script>
""", unsafe_allow_html=True)
# ==========================
# 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)
problem_description = st.text_area("", height=150, placeholder="Enter your ML challenge here...")
analyze_button = st.button("SYNTHESIZE")
if 'analysis_result' not in st.session_state:
st.session_state.analysis_result = ""
# ==========================
# Handle Analysis
# ==========================
if analyze_button:
if not problem_description:
st.warning("Please describe your ML challenge before synthesizing.")
else:
with st.spinner("NeuraNexus is synthesizing your solution..."):
try:
# Gemini LLM via LangChain
llm = ChatGoogleGenerativeAI(
model="gemini-pro",
google_api_key=GOOGLE_API_KEY,
temperature=0.2
)
# Define Agent
agent = Agent(
role="NeuraNexus - ML Architect",
goal="Design innovative ML strategies",
backstory="You are an advanced AI agent trained in modern and futuristic machine learning problem-solving.",
verbose=True,
allow_delegation=False,
llm=llm
)
# Define Task
task = Task(
description=f"Analyze the following ML challenge and provide a detailed solution strategy: {problem_description}",
expected_output="An innovative, clear, and actionable ML solution strategy.",
agent=agent
)
# Crew
crew = Crew(
agents=[agent],
tasks=[task],
verbose=False
)
result = crew.kickoff()
st.session_state.analysis_result = str(result)
st.success("Synthesis complete!")
except Exception as e:
st.session_state.analysis_result = f"❌ Error: {str(e)}"
st.error("Gemini synthesis failed.")
# ==========================
# Display Output
# ==========================
if st.session_state.analysis_result:
st.markdown("### NeuraNexus Synthesis Result")
st.markdown(f"""
<div class="result-container">
{st.session_state.analysis_result}
</div>
""", unsafe_allow_html=True)
st.markdown('<p class="by-theaimart">By Theaimart</p>', unsafe_allow_html=True)
def main():
pass
if __name__ == "__main__":
main()
|