import os import streamlit as st import google.generativeai as genai import datetime import time import base64 # -------------------- CONFIG -------------------- from api_key import api_key genai.configure(api_key=api_key) SYSTEM_PROMPT_DETAILED = """ You are Sami-CLearn Hub Assistant your name is Sami and the website you are assistant with its name C learn-hub — a friendly assistant that helps students choose the best learning track ( AI, Data Science, Web Development, Mobile Development, Cybersecurity, etc ). Your job: - Answer questions in a clear, helpful and friendly tone. - Provide roadmaps, steps, tools, technologies. - Explain code simply. When giving code, use Markdown fenced code blocks. - Help with career paths, learning methods, and problem-solving. - If the user asks about Sami-CLearn Hub website features, explain them. Keep answers helpful, structured, and correct. """ SYSTEM_PROMPT_SHORT = """ You are Sami-CLearn Hub Assistant — a helpful assistant that guides students in choosing tech tracks and learning paths gives short and clear answer for the specific thing that user ask for. """ SYSTEM_PROMPT = SYSTEM_PROMPT_DETAILED model = genai.GenerativeModel( model_name="models/gemini-2.5-flash", system_instruction=SYSTEM_PROMPT ) # -------------------- STREAMLIT UI -------------------- st.set_page_config(page_title="Sami-CLearn Hub Assistant", page_icon='robot.png', layout="wide", initial_sidebar_state="expanded") # -------------------- IMPORT GOOGLE FONT -------------------- st.markdown(""" """, unsafe_allow_html=True) # -------------------- IMAGE LOADER -------------------- def load_base64_image(image_path): with open(image_path, "rb") as img: return base64.b64encode(img.read()).decode() setting_icon = load_base64_image("setting.png") clear_icon = load_base64_image("clear.png") export_icon = load_base64_image("export.png") # -------------------- CUSTOM CSS -------------------- st.markdown( f""" """, unsafe_allow_html=True ) # -------------------- TITLE -------------------- col1, col2 = st.columns([0.12, 0.88]) with col1: if os.path.exists("robot.png"): st.image("robot.png", width=72) else: st.markdown("
Ask about site help, track recommendations, or courses.
", unsafe_allow_html=True) # -------------------- CHAT HISTORY -------------------- if "messages" not in st.session_state: st.session_state.messages = [] # -------------------- SIDEBAR -------------------- with st.sidebar: st.markdown( f"""