import streamlit as st import google.generativeai as genai import os import config import json import time from filter import is_solar_related # Import the solar query filter # Configure Gemini API genai.configure(api_key=config.API_KEY) def get_ai_response(user_input): model = genai.GenerativeModel("gemini-pro") # Using Gemini Pro model response = model.generate_content(user_input) return response.text if hasattr(response, "text") else "Error fetching response" # Set page config st.set_page_config( page_title="Solar Industry AI Assistant", page_icon="☀️", layout="wide", initial_sidebar_state="expanded" ) # Custom CSS for enhanced UI st.markdown(""" """, unsafe_allow_html=True) # Title with custom styling st.markdown('

🌞 Solar Industry AI Assistant

', unsafe_allow_html=True) st.markdown('

🔍 Ask any question related to solar energy, installation, cost, regulations, and more!

', unsafe_allow_html=True) # Session state for chat history if "chat_history" not in st.session_state: st.session_state.chat_history = [] # Create tabs for main content and about section tab1, tab2 = st.tabs(["💬 Chat Assistant", "👤 About Me"]) with tab1: # Layout with columns in the main chat tab col1, col2 = st.columns([3, 1]) with col1: # Query input with enhanced styling st.markdown('
', unsafe_allow_html=True) user_query = st.text_area("💡 Enter your question:", height=100) submit_button = st.button("⚡ Get Answer", use_container_width=True) st.markdown('
', unsafe_allow_html=True) if submit_button: if user_query.strip(): if is_solar_related(user_query): # Check if the query is solar-related with st.spinner("Thinking...💭"): time.sleep(1) # Simulate thinking animation response = get_ai_response(user_query) st.session_state.chat_history.append({"question": user_query, "answer": response}) # Display the current response in a nice box st.markdown('
', unsafe_allow_html=True) st.subheader("🤖 AI Response:") st.success(response) st.markdown('
', unsafe_allow_html=True) else: st.warning("⚠️ Please ask only solar energy-related questions.") else: st.warning("⚠️ Please enter a question.") # Chat history in sidebar in the main chat tab with col2: st.markdown('', unsafe_allow_html=True) # About Me Tab with tab2: st.markdown('
', unsafe_allow_html=True) # Profile section with columns for photo and details col1, col2 = st.columns([1, 2]) with col1: # Profile image placeholder (replace URL with actual image if available) st.markdown('', unsafe_allow_html=True) with col2: st.markdown("

Uditanshu Pandey

", unsafe_allow_html=True) st.markdown("

Course: B.Tech (Artificial Intelligence & Machine Learning)

", unsafe_allow_html=True) st.markdown("

College: Delhi Technical Campus, Greater Noida

", unsafe_allow_html=True) st.markdown("

Affiliation: Guru Gobind Singh Indraprastha University, New Delhi

", unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) # Introduction st.subheader("👋 Introduction") st.write(""" Enthusiastic and dedicated student with expertise in Python, data structures, algorithms, and machine learning. Proficient with scikit-learn, tensorflow, numpy, and pandas. Experienced with natural language processing. Currently preparing for the GATE exam to enhance my technical knowledge. I am eager to contribute to unique projects and thrive in a dynamic environment. """) # Skills section st.markdown('
', unsafe_allow_html=True) st.subheader("🛠️ Skills") # Programming Languages st.write("**Programming Languages:**") st.markdown('
' + 'Python' + 'C++' + 'Java' + '
', unsafe_allow_html=True) # Frameworks & Libraries st.write("**Frameworks & Libraries:**") st.markdown('
' + 'TensorFlow' + 'Scikit-learn' + 'NumPy' + 'Pandas' + 'Streamlit' + '
', unsafe_allow_html=True) # Areas of Interest st.write("**Areas of Interest:**") st.markdown('
' + 'Machine Learning' + 'Natural Language Processing' + 'Data Structures' + 'Algorithms' + 'Solar Energy' + '
', unsafe_allow_html=True) # Contact information st.markdown('
', unsafe_allow_html=True) st.subheader("📬 Contact") col1, col2, col3 = st.columns(3) with col1: st.markdown('', unsafe_allow_html=True) with col2: st.markdown('', unsafe_allow_html=True) with col3: st.markdown('', unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) # Footer st.markdown('
', unsafe_allow_html=True) st.markdown('

© 2025 Solar Industry AI Assistant | Developed by Uditanshu Pandey

', unsafe_allow_html=True)