File size: 10,129 Bytes
b4f404b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
import execution.euron_streamlit as st
from src.helper import download_hugging_face_embeddings
from langchain_pinecone import PineconeVectorStore
from langchain.chains import create_retrieval_chain
from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_core.prompts import ChatPromptTemplate
from src.prompt import *
from src.euron_chat import EuronChatModel
from dotenv import load_dotenv
import os

# Load environment variables
load_dotenv()
pinecone_api_key = os.getenv("PINECONE_API_KEY")
euron_api_key = os.getenv("EURON_API_KEY")

if not pinecone_api_key or not euron_api_key:
    st.error("Missing keys in environment")
    st.stop()

# βœ… Minimal CSS – Only apply Fira Code font globally + Sidebar styling
st.markdown("""
<style>
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');

/* Global font */
* {
    font-family: 'Fira Code', monospace !important;
}

/* Sidebar background & padding */
[data-testid="stSidebar"] {
    background-color: #f0f2f6 !important; /* Light ash */
    border-radius: 0 20px 20px 0;
    padding: 25px 15px;
}

/* Sidebar title */
[data-testid="stSidebar"] .css-1d391kg {
    color: #1f2937 !important;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 25px;
}

/* Sidebar radio buttons as styled buttons */
[data-testid="stSidebar"] .stRadio > div {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
[data-testid="stSidebar"] .stRadio label {
    background-color: rgba(31,41,55,0.1) !important; /* subtle gray */
    color: #1f2937 !important;
    padding: 12px 18px;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
}
[data-testid="stSidebar"] .stRadio label:hover {
    background-color: rgba(31,41,55,0.2) !important;
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
[data-testid="stSidebar"] .stRadio input:checked + label {
    background-color: #4B5563 !important; /* Darker for selected */
    color: #ffffff !important;
}

/* Sidebar image */
[data-testid="stSidebar"] img {
    border-radius: 15px;
    margin-bottom: 20px;
}

/* Sidebar divider */
[data-testid="stSidebar"] hr {
    border: 1px solid rgba(0,0,0,0.2) !important;
    margin: 20px 0;
}

/* Sidebar caption */
[data-testid="stSidebar"] .css-1x8i1po {
    text-align: center;
    font-size: 0.9rem;
    color: #4b5563 !important;
    margin-top: 15px;
}
</style>
""", unsafe_allow_html=True)

# Sidebar Menu
with st.sidebar:
    # st.title("🌟 Navigation")
    st.image("static/icon.png", width=120)  # Image in sidebar
    st.markdown("---")
    menu = st.radio("Go to", ["About Me", "Chatbot"], label_visibility="hidden")
    st.markdown("---")
    st.caption("Β© 2025 Shanin Hossain")
    # st.markdown("""
    # <div style="text-align:center; margin-top: 15px;">
    #     <a href="https://www.linkedin.com/in/shanin-hossain" target="_blank">
    #         <img src="https://cdn.jsdelivr.net/gh/simple-icons/simple-icons/icons/linkedin.svg" width="25" style="margin:0;">
    #     </a>
    #     <a href="https://github.com/shaninhossain" target="_blank">
    #         <img src="https://cdn.jsdelivr.net/gh/simple-icons/simple-icons/icons/github.svg" width="25" style="margin:0;">
    #     </a>
    #     <a href="https://www.facebook.com/shaninhossain" target="_blank">
    #         <img src="https://cdn.jsdelivr.net/gh/simple-icons/simple-icons/icons/facebook.svg" width="25" style="margin:0;">
    #     </a>
    # </div>
    # """, unsafe_allow_html=True)



# Initialize session state
if "rag_chain" not in st.session_state:
    st.session_state.rag_chain = None
    st.session_state.embeddings = None
    st.session_state.retriever = None
if "messages" not in st.session_state:
    st.session_state.messages = []  # Chat history

def initialize_rag():
    try:
        if st.session_state.rag_chain is None:
            st.session_state.embeddings = download_hugging_face_embeddings()
            index_name = "portfolio"
            docsearch = PineconeVectorStore.from_existing_index(
                index_name=index_name,
                embedding=st.session_state.embeddings
            )
            st.session_state.retriever = docsearch.as_retriever(
                search_type="similarity", search_kwargs={"k": 3}
            )
            chatModel = EuronChatModel()
            prompt = ChatPromptTemplate.from_messages(
                [
                    ("system", system_prompt),
                    ("human", "{input}"),
                ]
            )
            question_answer_chain = create_stuff_documents_chain(chatModel, prompt)
            st.session_state.rag_chain = create_retrieval_chain(
                st.session_state.retriever, question_answer_chain
            )
    except Exception as e:
        st.error(f"Error initializing RAG: {str(e)}")
        st.stop()

# About Me Section
# About Me Section
if menu == "About Me":
    st.write("Hey there πŸ‘‹")
    st.title("πŸ‘¨ I'm Shanin Hossain")
    st.markdown("""
    I'm an AI Engineer & Research Assistant passionate about:
    - Machine Learning, Deep Learning, and Generative AI  
    - Computer Vision & Natural Language Processing  
    - Healthcare Informatics and Medical Imaging  
    
    πŸ“Œ I have worked on multiple AI projects, including OCR, Retrieval-Augmented Generation (RAG), and hybrid graph networks.  
    """)
    st.success("πŸ‘‰ Navigate to **Chatbot** in the sidebar to chat with me!")
    st.header("My Projects", divider="gray")

    # --- Project Data ---
    projects = [
        {
            "name": "Brain Glioma Grading System",
            "description": "Developed a hybrid graph neural network to grade glioma tumors from medical imaging data.",
            "tech_stack": ["PyTorch Geometric", "Graph Neural Networks", "Medical Imaging", "Python"]
        },
        {
            "name": "OCR Automation",
            "description": "Built an OCR pipeline for document image understanding and text extraction.",
            "tech_stack": ["YOLOv8", "OpenCV", "Tesseract OCR", "FastAPI"]
        },
        {
            "name": "Portfolio Chatbot",
            "description": "Created a RAG-powered chatbot integrated with Pinecone & custom embeddings for Q&A over portfolio data.",
            "tech_stack": ["Streamlit", "LangChain", "Pinecone", "Hugging Face"]
        },
    ]

    # --- Render Projects with Badges ---
    for project in projects:
        with st.container():
            st.subheader(project["name"])
            st.write(project["description"])

            # Create badges for each tech in stack
            badges_html = " ".join([
                f"<span class='badge'>{tech}</span>" for tech in project["tech_stack"]
            ])

            st.markdown(
                f"<div style=''>{badges_html}</div>",
                unsafe_allow_html=True
            )

            st.markdown("---")

    # --- Badge Styling ---
    st.markdown("""
    <style>
    .badge {
        display: inline-block;
        padding: 6px 12px;
        font-size: 0.70rem;
        font-weight: 600;
        color: white;
        border-radius: 12px;
    }

    /* Randomized color palette */
    .badge:nth-child(5n+1) { background-color: #2563EB; }  /* Blue */
    .badge:nth-child(5n+2) { background-color: #059669; }  /* Green */
    .badge:nth-child(5n+3) { background-color: #D97706; }  /* Orange */
    .badge:nth-child(5n+4) { background-color: #9333EA; }  /* Purple */
    .badge:nth-child(5n+5) { background-color: #DC2626; }  /* Red */
    </style>
    """, unsafe_allow_html=True)


    st.header("Publications", divider="gray")

    # --- Publication Data ---
    publications = [
        {
            "title": "Automated Detection of Age-Related Macular Degeneration (AMD) Using Deep Learning",
            "venue": "Journal of Medical Imaging & Health Informatics, 2023",
            "description": "Published a deep learning-based pipeline to detect age-related macular degeneration from retinal images.",
            "link": "https://doi.org/xxxxxx"
        },
        {
            "title": "Using Hyperdimensional Computing to Extract Features for the Detection of Type 2 Diabetes",
            "venue": "Conference on Health Informatics, 2024 (Under Review)",
            "description": "Explored hyperdimensional computing techniques to improve detection of Type 2 Diabetes from clinical data.",
            "link": ""
        }
    ]

    # --- Render Publications ---
    for pub in publications:
        with st.container():
            st.subheader(pub["title"])
            st.caption(pub["venue"])
            st.write(pub["description"])

            if pub["link"]:
                st.markdown(f"[πŸ”— View Publication]({pub['link']})")

            st.markdown("---")



# Chatbot Section
elif menu == "Chatbot":
    st.title("πŸ€– Shanin Chatbot")
    st.write("Ask me anything about my portfolio!")

    # Display previous messages
    for msg in st.session_state.messages:
        with st.chat_message(msg["role"]):
            st.write(msg["content"])

    # Input box
    if prompt := st.chat_input("Type your question..."):
        # Add user message
        st.session_state.messages.append({"role": "user", "content": prompt})
        with st.chat_message("user"):
            st.write(prompt)

        # Initialize RAG if needed
        if st.session_state.rag_chain is None:
            with st.spinner("Initializing RAG pipeline..."):
                initialize_rag()

        try:
            with st.spinner("Generating response..."):
                response = st.session_state.rag_chain.invoke({"input": prompt})
                answer = response["answer"]

                # Add assistant response
                st.session_state.messages.append({"role": "assistant", "content": answer})
                with st.chat_message("assistant"):
                    st.write(answer)

        except Exception as e:
            st.error(f"Error processing request: {str(e)}")