import streamlit as st
from groq import Groq
import pandas as pd
import random
# Set up the page configuration
st.set_page_config(page_title="PAK ANGELS AI MEGA_BOT", page_icon="🤖", layout="centered")
# Display the logo in the center
st.image("logo.png", width=1000) # Adjust the width as needed
# Clickable logo with a website link
#st.markdown("""
#
#""", unsafe_allow_html=True)
# Streamlit page setup
#st.set_page_config(page_title="PAK ANGELS AI MEGA_BOT", page_icon="🤖", layout="centered")
st.title("PAK ANGELS AI MEGA_BOT")
st.sidebar.image("logo.png") # Add your logo path here
st.sidebar.header("Topics")
# Define the theme colors
st.markdown("""
""", unsafe_allow_html=True)
# Connect to the Groq API using the provided key
client = Groq(api_key="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")
import streamlit as st
# Sidebar Menu with topics and subtopics
topics = {
"Artificial Intelligence": ["Overview", "Applications", "Future Prospects"],
"Generative AI": ["Introduction", "Applications", "Ethics"],
"Specific Models": ["GPT", "BERT", "Electra", "Gemma2-9b-it"],
"Building Applications": ["With RAG", "Without RAG"]
}
# Sidebar Topic Selection
st.sidebar.title("AI & Gen AI Topics")
selected_topic = None
selected_subtopic = None
# Sidebar selection for topics and subtopics
for topic, subtopics in topics.items():
with st.sidebar.expander(topic, expanded=False):
selected_subtopic = st.radio("Select a Subtopic", subtopics, key=topic)
if selected_subtopic:
selected_topic = topic
# Checkbox to confirm user is ready to view response
show_response = st.sidebar.checkbox("Show response")
# Display title based on subtopic selection
if selected_subtopic:
st.title(f"MEGA_BOT - {selected_subtopic}")
else:
st.title("Welcome to PAK ANGELS AI Chatbot")
# Function to generate response using Groq model
def generate_response(prompt):
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": prompt}],
model="gemma2-9b-it",
stream=False
)
return chat_completion.choices[0].message.content
# Mapping of topic-subtopic pairs to prompts
prompts = {
("Artificial Intelligence", "Overview"): """
Explain the overview of Artificial Intelligence (AI) in a detailed manner.
Break down the explanation into simple, easy-to-understand points for beginners, avoiding technical jargon.
Make it long and creative, and include practical examples and analogies where possible.
""",
("Artificial Intelligence", "Applications"): """
Explain the main applications of Artificial Intelligence in various industries.
Break it down into point-wise, simple, and creative explanations suitable for a beginner.
Include examples from everyday life to make it relatable.
""",
("Artificial Intelligence", "Future Prospects"): """
What are the future prospects of Artificial Intelligence, and how will it evolve?
Provide a detailed response with creative ideas, breaking it down into simple, easy-to-understand points.
Consider the potential positive and negative impacts on society.
""",
("Generative AI", "Introduction"): """
Provide an introduction to Generative AI and its core principles.
Use simple, beginner-friendly language and provide creative explanations with examples.
Break it down into points and keep the response long and informative.
""",
("Generative AI", "Applications"): """
Explain the key applications of Generative AI in various fields.
Break the explanation into simple, easy-to-understand points, and use examples.
Make the response long and creative with real-world use cases.
""",
("Generative AI", "Ethics"): """
What are the ethical concerns related to Generative AI and its usage?
Provide a detailed, easy-to-understand explanation with examples.
Break down the explanation into simple, point-wise sections suitable for a beginner.
""",
("Specific Models", "GPT"): """
Explain the GPT (Generative Pretrained Transformer) model and its capabilities.
Break the explanation down into beginner-friendly, simple points.
Use analogies and relatable examples to make it creative and easy to understand.
""",
("Specific Models", "BERT"): """
Explain the BERT (Bidirectional Encoder Representations from Transformers) model.
Provide a detailed, easy-to-understand response with simple points and examples.
Use creative language to explain complex concepts simply.
""",
("Specific Models", "Electra"): """
Describe the Electra model and its applications.
Break the explanation into simple, easy-to-understand points, and keep it creative and beginner-friendly.
Provide relatable examples where possible.
""",
("Specific Models", "Gemma2-9b-it"): """
What is the Gemma2-9b-it model, and what makes it unique?
Break down the explanation into points and make it understandable for a beginner.
Include simple examples and analogies to help explain the key features and capabilities.
""",
("Building Applications", "With RAG"): """
Explain how to build applications using Retrieval-Augmented Generation (RAG).
Break it down into beginner-friendly points with creative examples and analogies.
Provide a detailed yet simple explanation for non-technical users.
""",
("Building Applications", "Without RAG"): """
Explain how to build applications without using Retrieval-Augmented Generation (RAG).
Provide a detailed, easy-to-understand explanation with creative examples.
Break down the response into simple, point-wise sections for beginners.
"""
}
# Display response based on the selected subtopic only if the checkbox is checked
if selected_subtopic and selected_topic and show_response:
# Retrieve the prompt based on the selected topic and subtopic
prompt = prompts.get((selected_topic, selected_subtopic), "No prompt available for this selection.")
# Generate the response based on the prompt using the Groq model
response = generate_response(prompt)
# Display the model's response
st.write(response)
elif not show_response:
# Display a message prompting the user to check the box if it is not checked
st.write("Please select a topic and subtopic from the sidebar and check 'Show response' to see more information.")
# Sample dataset for resources
data_sessions = pd.DataFrame({
"Session Name": ["Introduction to Generative AI", "Python Practice For Beginners", "Practice Session for Creating Simple Calculator App", "Voice_To_Voice Chatbot", "Simple RAG Based App", "Earning From Learning GEN_AI"],
"Topics": ["Introduction to Generative AI - Technical Terms", "Online Dev Platforms & Python with ChatGPT", "Online Dev Platforms & Python with ChatGPT Part-2", "Developing a Generative AI Application", "Making Your Generative AI Application Real", "How to Sell Your Generative AI Skill"],
"YouTube Link": ["https://www.youtube.com/live/wiu8_9mRv-0", "https://www.youtube.com/live/qdpiKRIMWs8?si=h7x3aXbqMZ6ZwTrx", "https://www.youtube.com/live/bZtjueXYSek?feature=shared", "https://www.youtube.com/live/HAPevCGQSpc?si=d0vCKo1XcbOrciNd", "https://www.youtube.com/live/UwjJXHdtXlY?si=6aErs2Qggw103Dsp", "https://www.youtube.com/live/hpqS3AbZbG8?si=-R2AsZC9mhaQ-ShQ"],
"Slides Link": ["https://docs.google.com/presentation/d/1KwKcSY3flZjLtaUonlJ5Zf58FOAG1Xaew0IjITUqTKQ/edit?usp=sharing", "https://docs.google.com/presentation/d/1OZ-gQ0KJuZymE5xrO6vTtqhkVn2rXgpa/edit?usp=sharing&ouid=116194473458482782656&rtpof=true&sd=true", "https://docs.google.com/presentation/d/11MofdNQEaJFwJyZd-QM3rn0me5cfpCuK/edit?usp=sharing&ouid=104137823405854476802&rtpof=true&sd=true", "NA", "https://1drv.ms/p/c/879d382112d53618/EUBlYSbrQ9dPrrRjxGUmQlEBdz5kEJ00nbGUYIKuqIrK-g", "NA"],
"Code Link": ["https://colab.research.google.com/drive/11OMJ1hFY58l61v4vyen45kieTHXmJnpf?usp=sharing#scrollTo=ksBBSxOD14pm",
"https://colab.research.google.com/drive/1WvL3HDCKnlY569Qv39CW1UFT5ETz5ZJY?usp=sharing",
"https://colab.research.google.com/drive/1bMHEfIZBRAoNS1V5NrvfhMDadQ88MuRD?usp=sharing", "https://colab.research.google.com/drive/1yw4BeDdXeoB3hCZpFJU38r05eqytzafW?usp=sharing , https://chatgpt.com/share/6713db85-e0c4-8000-ac77-0d2bce1c3933", "https://colab.research.google.com/drive/1zTuFz0sWujtvUgg9154UFhD6n7pFqQIB#scrollTo=GVXP_nmPIwDi , https://colab.research.google.com/drive/1-ttYhyLFTTsbo8AqfZraePY7m5G79Ex2?usp=sharing", "https://www.canva.com/design/DAGO2_qRPZU/7iqi2vyMWGBj-Zdc696qSA/edit?utm_content=DAGO2_qRPZU&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton"],
"Moderator Name": ["Hasnain Ali", "Zulifiqar Ali Mir, Muhammad Talha", "Zulfiqar Ali Mir", "Muhammad Danish Iqbal", "Muhammad Talha , Muhammad Osama Ghaffar", "Muhammad Anwar Khan , Afeefa Batool , Mohsin Iqbal"]
})
st.title("Curated Educational Resources")
# Display all unique topics as selectable options
topic_options = data_sessions["Topics"].unique()
selected_topic = st.selectbox("Select a Topic:", topic_options)
# Display resources based on the selected topic
if selected_topic:
relevant_sessions = data_sessions[data_sessions['Topics'] == selected_topic]
if not relevant_sessions.empty:
st.write(f"Resources for: **{selected_topic}**")
st.table(relevant_sessions)
else:
st.write("No resources found for the selected topic.")
# Display all resources if checkbox is selected
if st.checkbox("Show All Topics"):
st.dataframe(data_sessions)
# Load the CSV file into a DataFrame
data_sessions = pd.read_csv("dataset_1 .csv") # Replace with the path to your CSV file
# Load the CSV file into a DataFrame
data_sessions = pd.read_csv("dataset_2 .csv") # Replace with the path to your CSV file
# Display all resources if checkbox is selected
if st.checkbox("Show All Resources"):
st.dataframe(data_sessions)
# User Input and Chatbot Interaction
st.header("Ask MEGA_BOT anything about AI and Generative AI!")
def ask_groq_model(question):
response = client.chat.completions.create(
messages=[{"role": "user", "content": question}],
model="gemma2-9b-it",
stream=False
)
return response.choices[0].message.content
# Chat interaction
question = st.text_input("Type your question here:")
if st.button("Ask"):
if question:
with st.spinner("Thinking..."):
answer = ask_groq_model(question)
st.write(answer)
else:
st.warning("Please enter a question!")
# Display resources based on user question or selected topic
#if st.checkbox("Show resources related to my question"):
# relevant_sessions = data_sessions[data_sessions['Topics'].str.contains(question, case=False, na=False)]
# if relevant_sessions.empty:
# st.write("No specific resources found for this topic. Here are some general resources.")
# st.dataframe(data_sessions)
# else:
# st.write("Here are resources related to your question:")
# st.dataframe(relevant_sessions)
# Quiz data
quiz_data = {
"Intro to AI": [
{"question": "What is the primary goal of AI?", "options": ["To mimic human intelligence", "To replace all jobs", "To create games"], "answer": "To mimic human intelligence"},
{"question": "What does ML stand for?", "options": ["Machine Learning", "Media Link", "Mathematics Logic"], "answer": "Machine Learning"}
],
"Generative AI Basics": [
{"question": "What is Generative AI used for?", "options": ["Creating new content", "Deleting data", "Just making charts"], "answer": "Creating new content"},
{"question": "Name a popular generative AI model?", "options": ["GPT", "Excel", "Random Forest"], "answer": "GPT"}
]
}
# Load the CSV file into a DataFrame
data_sessions = pd.read_csv("dataset_1 .csv") # Replace with the path to your CSV file
# Load the CSV file into a DataFrame
#data_sessions = pd.read_csv("dataset_2 .csv") # Replace with the path to your CSV file
# Quiz Section
st.subheader("Interactive Quizzes")
selected_session = st.selectbox("Choose a session to test your knowledge:", list(quiz_data.keys()))
if selected_session:
quiz = quiz_data[selected_session]
score = 0
for q in quiz:
st.write(q["question"])
option = st.radio("Choose an answer:", q["options"], key=q["question"])
if option == q["answer"]:
score += 1
st.success("Correct!")
else:
st.error("Incorrect!")
st.write(f"Your score for {selected_session}: {score}/{len(quiz)}")
# Simulation Section: Model Demo
st.subheader("Try Out Generative AI")
st.write("Adjust the settings below to see how Generative AI responses change:")
# Sample simulation controls
temperature = st.slider("Temperature (creativity level)", min_value=0.0, max_value=1.0, value=0.5)
max_tokens = st.slider("Response length", min_value=10, max_value=100, value=50)
if st.button("Generate Example Response"):
# Use example question for demonstration purposes
example_question = "Explain Generative AI in simple terms."
demo_response = client.chat.completions.create(
messages=[{"role": "user", "content": example_question}],
model="gemma2-9b-it",
temperature=temperature,
max_tokens=max_tokens,
stream=False
)
st.write(demo_response.choices[0].message.content)
# Feedback Section
st.subheader("Help Us Improve!")
feedback = st.text_area("What did you think of the chatbot's response? Any suggestions?")
if st.button("Submit Feedback"):
if feedback:
st.success("Thank you for your feedback!")
else:
st.warning("Please enter your feedback before submitting.")
st.info("This chatbot provides simplified explanations and examples to help you understand AI, Generative AI, and related topics.")
st.success("Enjoy exploring the interactive quizzes, model simulations, and helpful resources!")
st.markdown("""
Contact Us
Email: suhanirazzaq@gmail.com
Phone Number: +923162132748
""", unsafe_allow_html=True)
# Add "MADE BY SILVER ANGELS" with a link at the end of the page
st.markdown("""
""", unsafe_allow_html=True)