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("""
""", unsafe_allow_html=True)
# ==========================
# 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)
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"""
{st.session_state.analysis_result}
""", unsafe_allow_html=True)
st.markdown('By Theaimart
', unsafe_allow_html=True)
def main():
pass
if __name__ == "__main__":
main()