Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from groq import Groq
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
# Function to interact with the model
|
| 7 |
def get_model_response(prompt):
|
|
@@ -22,10 +24,27 @@ def get_model_response(prompt):
|
|
| 22 |
return f"An error occurred: {str(e)}"
|
| 23 |
|
| 24 |
# Streamlit App
|
| 25 |
-
st.
|
| 26 |
-
st.write("This app allows you to interact with a Groq-powered AI model.")
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
if st.button("Get Response"):
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from groq import Groq
|
| 3 |
+
import time
|
| 4 |
|
| 5 |
+
# API Key (replace with yours)
|
| 6 |
+
API_KEY = "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"
|
| 7 |
|
| 8 |
# Function to interact with the model
|
| 9 |
def get_model_response(prompt):
|
|
|
|
| 24 |
return f"An error occurred: {str(e)}"
|
| 25 |
|
| 26 |
# Streamlit App
|
| 27 |
+
st.set_page_config(page_title="AI Chat Interface", page_icon="") # Set title and icon
|
|
|
|
| 28 |
|
| 29 |
+
# Add a header with logo (optional)
|
| 30 |
+
st.markdown("""
|
| 31 |
+
<div style="text-align: center;">
|
| 32 |
+
<img src="https://placehold.it/150x150" alt="Logo" style="border-radius: 50%;">
|
| 33 |
+
<h1>AI Chat Interface</h1>
|
| 34 |
+
</div>
|
| 35 |
+
""", unsafe_allow_html=True)
|
| 36 |
+
|
| 37 |
+
# Progress bar animation for loading
|
| 38 |
+
with st.spinner("Thinking..."):
|
| 39 |
+
time.sleep(2) # Simulate processing time
|
| 40 |
+
|
| 41 |
+
user_input = st.text_input("Your Prompt", placeholder="Type your question here...", key="prompt")
|
| 42 |
+
|
| 43 |
+
# Display "Thinking..." animation while fetching response
|
| 44 |
if st.button("Get Response"):
|
| 45 |
+
with st.spinner("Fetching Response..."):
|
| 46 |
+
response = get_model_response(user_input)
|
| 47 |
+
st.write(f"**Model Response:** {response}")
|
| 48 |
+
|
| 49 |
+
# Success message animation
|
| 50 |
+
st.success("Response retrieved successfully!")
|