Spaces:
Sleeping
Sleeping
File size: 2,343 Bytes
066505e ec0716b ffb99d3 ec0716b bb7b215 ffb99d3 bb7b215 ffb99d3 bb7b215 674c6ba bb7b215 79d880e bb7b215 9260a76 79d880e ffb99d3 79d880e 5c43d8c |
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 |
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
st.set_page_config(page_title="AI Chatbot", page_icon=":robot:") # Set app title and icon
def main():
# Layout with sidebar
col1, col2 = st.beta_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()
|