JohnAlexander23's picture
Update app.py
3b445f4 verified
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."},
{"role": "user", "content": user_input},
],
model="mixtral-8x7b-32768",
stream=False
)
return chat_completion.choices[0].message.content
# Set page config
st.set_page_config(
page_title="CyberChat",
page_icon="πŸ€–",
layout="wide",
initial_sidebar_state="expanded"
)
# Cyberpunk style CSS
cyberpunk_style = """
<style>
body {
color: #8AFF80;
background-color: #0D0D0D;
}
.stButton>button {
color: #8AFF80 !important;
background-color: #0D0D0D !important;
border-color: #8AFF80 !important;
font-family: 'Orbitron', sans-serif;
border-radius: 20px;
}
.stTextInput>div>div>input {
color: #8AFF80 !important;
background-color: #0D0D0D !important;
border-color: #8AFF80 !important;
font-family: 'Orbitron', sans-serif;
}
.stTextInput>div>div>input::placeholder {
color: #8AFF80 !important;
}
.stTextInput>div>div>input:focus {
border-color: #8AFF80 !important;
box-shadow: 0 0 0 0.2rem rgba(138, 255, 163, 0.5) !important;
}
footer {
color: #8AFF80;
font-size: small;
text-align: right;
font-family: 'Orbitron', sans-serif;
}
</style>
"""
# Streamlit app
st.markdown(cyberpunk_style, unsafe_allow_html=True)
st.title("CyberChat")
st.subheader("Ask a question and get a response.")
# Text input for user's question
user_input = st.text_input("Enter your question here:")
# Button to trigger response
if st.button("Get Response"):
# Fetch and display response
response = fetch_response(user_input)
st.write("Response:", response)
# Footer
st.markdown(
"""
<footer>
By DL Titans
</footer>
""",
unsafe_allow_html=True
)