Spaces:
Sleeping
Sleeping
JohnAlexander23
commited on
Commit
•
5a18d50
1
Parent(s):
caa3e40
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from groq import Groq
|
3 |
+
|
4 |
+
# Define the API key here
|
5 |
+
GROQ_API_KEY = "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"
|
6 |
+
|
7 |
+
# Define function to fetch response
|
8 |
+
def fetch_response(user_input):
|
9 |
+
client = Groq(api_key=GROQ_API_KEY)
|
10 |
+
chat_completion = client.chat.completions.create(
|
11 |
+
messages=[
|
12 |
+
{"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."},
|
13 |
+
{"role": "user", "content": user_input},
|
14 |
+
],
|
15 |
+
model="mixtral-8x7b-32768",
|
16 |
+
stream=False
|
17 |
+
)
|
18 |
+
return chat_completion.choices[0].message.content
|
19 |
+
|
20 |
+
# Streamlit app
|
21 |
+
st.title("Fastest AI Chatbot")
|
22 |
+
st.write("Ask a question and get a response.")
|
23 |
+
|
24 |
+
# Text input for user's question
|
25 |
+
user_input = st.text_input("Enter your question here:")
|
26 |
+
|
27 |
+
# Button to trigger response
|
28 |
+
if st.button("Get Response"):
|
29 |
+
# Fetch and display response
|
30 |
+
response = fetch_response(user_input)
|
31 |
+
st.write("Response:", response)
|
32 |
+
|
33 |
+
# Footer
|
34 |
+
st.markdown(
|
35 |
+
"""
|
36 |
+
<footer style="color: blue; font-size: small; text-align: right;">
|
37 |
+
By DL TITANS
|
38 |
+
</footer>
|
39 |
+
""",
|
40 |
+
unsafe_allow_html=True
|
41 |
+
)
|
42 |
+
|