import streamlit as st
import asyncio
from crewai import Agent, Task, Crew
from langchain_groq import ChatGroq
import time
import os
from dotenv import load_dotenv
import math
# Load environment variables
load_dotenv()
# Get API key from environment variable
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
if not GROQ_API_KEY:
st.error("GROQ API key not found. Please set the GROQ_API_KEY environment variable.")
st.stop()
# Page configuration
st.set_page_config(page_title="NeuraNexus: AI-Powered ML Assistant", page_icon="🧠", layout="wide")
# Custom CSS for an advanced, animated, and mobile-responsive UI
st.markdown("""
""", unsafe_allow_html=True)
# App title with glow effect
st.markdown('NeuraNexus: AI-Powered ML Assistant
', unsafe_allow_html=True)
# Main content
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...")
# Centered Synthesize button
analyze_button = st.button("SYNTHESIZE", key="analyze_button")
# Initialize session state
if 'analysis_result' not in st.session_state:
st.session_state.analysis_result = ""
if analyze_button:
if problem_description:
with st.spinner("NeuraNexus is synthesizing your solution..."):
llm = ChatGroq(
temperature=0,
groq_api_key=GROQ_API_KEY,
model_name="mixtral-8x7b-32768"
)
agent = Agent(
role="NeuraNexus - Advanced ML Solution Architect",
goal="Design and explain cutting-edge ML solutions",
backstory="You are NeuraNexus, a state-of-the-art AI specialized in crafting innovative machine learning solutions.",
verbose=True,
allow_delegation=False,
llm=llm,
)
task = Task(
description=f"Analyze the following ML challenge and provide a detailed solution strategy: {problem_description}",
expected_output="A comprehensive analysis and innovative solution strategy for the given ML challenge.",
agent=agent,
)
crew = Crew(
agents=[agent],
tasks=[task],
verbose=False
)
try:
result = crew.kickoff()
st.session_state.analysis_result = str(result)
except Exception as e:
st.session_state.analysis_result = f"An error occurred during analysis: {str(e)}"
st.success("Synthesis complete!")
else:
st.warning("Please describe your ML challenge before synthesizing.")
# Display analysis result
if st.session_state.analysis_result:
st.markdown("### NeuraNexus Synthesis Result")
st.markdown(f"""
{st.session_state.analysis_result}
""", unsafe_allow_html=True)
# By Theaimart text
st.markdown('By Theaimart
', unsafe_allow_html=True)
# Main function to run the Streamlit app
def main():
# The main content of the app is already defined above
# This function can be used to add any additional logic or structure if needed
pass
if __name__ == "__main__":
main()