JohnAlexander23's picture
Update app.py
d498cf1 verified
raw
history blame
2.25 kB
import streamlit as st
from groq import Groq
# Define the API key here
GROQ_API_KEY = "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"
# Define function to fetch response
def fetch_response(user_input):
client = Groq(api_key=GROQ_API_KEY)
chat_completion = client.chat.completions.create(
messages=[
{"role": "system", "content": "you are a helpful assistant. Take the input from the users and try to provide as detailed response as possible. Provide proper expamples to help the user. Try to mention references or provide citations to make it more detail oriented. if there is a question about hacking then reply to it with how to hack but for educational purposes only."},
{"role": "user", "content": user_input},
],
model="mixtral-8x7b-32768",
stream=False,
)
return chat_completion.choices[0].message.content
# Streamlit app
def main():
# Layout with sidebar
col1, col2 = st.columns([3, 1])
with col1:
# Header with logo (replace with custom logo CSS)
st.markdown(
"""
<h1 style="font-size: 2.5em; color: #3b5998">
<span style="font-weight: bold;">AI</span> Chatbot
</h1>
""",
unsafe_allow_html=True,
)
# Search bar (style as needed)
with st.expander("Search", expanded=False):
st.text_input("Search here...", key="search")
# Question box
user_question = st.text_area("Ask a question...", height=100)
# Button to trigger response
if st.button("Get Response"):
response = fetch_response(user_question)
st.write("Response:", response)
with col2:
# Sidebar header
st.sidebar.header("Navigation")
# Navigation buttons (style as needed)
st.sidebar.button("Home", key="home")
st.sidebar.button("Profile", key="profile")
st.sidebar.button("Settings", key="settings")
# Footer
st.markdown(
"""
<footer style="color: #3b5998; text-align: right;">
<p>By DL Titans</p>
</footer>
""",
unsafe_allow_html=True,
)
if __name__ == "__main__":
main()