Update src/streamlit_app.py
Browse files- src/streamlit_app.py +53 -16
src/streamlit_app.py
CHANGED
|
@@ -1,28 +1,65 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
st.set_page_config(page_title="
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
st.markdown("---")
|
| 8 |
|
| 9 |
-
# --- API
|
| 10 |
-
#
|
| 11 |
-
GROQ_API_KEY = "
|
| 12 |
-
|
| 13 |
|
| 14 |
-
# Chat history initialization
|
| 15 |
if "messages" not in st.session_state:
|
| 16 |
st.session_state.messages = []
|
| 17 |
|
| 18 |
-
#
|
| 19 |
for msg in st.session_state.messages:
|
| 20 |
with st.chat_message(msg["role"]):
|
| 21 |
st.markdown(msg["content"])
|
| 22 |
|
| 23 |
# User Input
|
| 24 |
-
if prompt := st.chat_input("
|
| 25 |
-
# User message display aur save
|
| 26 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 27 |
with st.chat_message("user"):
|
| 28 |
st.markdown(prompt)
|
|
@@ -34,12 +71,12 @@ if prompt := st.chat_input("Ask Me Everything"):
|
|
| 34 |
"Content-Type": "application/json"
|
| 35 |
}
|
| 36 |
payload = {
|
| 37 |
-
"model":
|
| 38 |
"messages": [
|
| 39 |
-
{"role": "system", "content": "You are
|
| 40 |
{"role": "user", "content": prompt}
|
| 41 |
],
|
| 42 |
-
"temperature": 0.
|
| 43 |
}
|
| 44 |
|
| 45 |
with st.chat_message("assistant"):
|
|
@@ -50,7 +87,7 @@ if prompt := st.chat_input("Ask Me Everything"):
|
|
| 50 |
st.markdown(answer)
|
| 51 |
st.session_state.messages.append({"role": "assistant", "content": answer})
|
| 52 |
else:
|
| 53 |
-
st.error(
|
| 54 |
except Exception as e:
|
| 55 |
-
st.error(f"
|
| 56 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
# --- PAGE CONFIG ---
|
| 6 |
+
st.set_page_config(page_title="YURI AI PRO", page_icon="π§¬", layout="centered")
|
| 7 |
+
|
| 8 |
+
# --- CUSTOM DESIGN (CSS) ---
|
| 9 |
+
st.markdown("""
|
| 10 |
+
<style>
|
| 11 |
+
.main {
|
| 12 |
+
background-color: #0e1117;
|
| 13 |
+
}
|
| 14 |
+
.stChatMessage {
|
| 15 |
+
border-radius: 15px;
|
| 16 |
+
padding: 10px;
|
| 17 |
+
margin-bottom: 10px;
|
| 18 |
+
}
|
| 19 |
+
.stTitle {
|
| 20 |
+
color: #00f2fe;
|
| 21 |
+
font-family: 'Trebuchet MS';
|
| 22 |
+
text-align: center;
|
| 23 |
+
text-shadow: 2px 2px 10px #00f2fe;
|
| 24 |
+
}
|
| 25 |
+
div[data-testid="stSidebar"] {
|
| 26 |
+
background-color: #161b22;
|
| 27 |
+
border-right: 1px solid #00f2fe;
|
| 28 |
+
}
|
| 29 |
+
</style>
|
| 30 |
+
""", unsafe_allow_html=True)
|
| 31 |
+
|
| 32 |
+
# --- SIDEBAR DESIGN ---
|
| 33 |
+
with st.sidebar:
|
| 34 |
+
st.title("βοΈ YURI SETTINGS")
|
| 35 |
+
st.info("Yuri AI is now in Pro Mode.")
|
| 36 |
+
st.markdown("---")
|
| 37 |
+
st.write("π€ **Creator:** Your Name")
|
| 38 |
+
st.write("π€ **Model:** Llama 3.3 (Fast)")
|
| 39 |
+
if st.button("Clear Chat History"):
|
| 40 |
+
st.session_state.messages = []
|
| 41 |
+
st.rerun()
|
| 42 |
+
|
| 43 |
+
# --- HEADER ---
|
| 44 |
+
st.title("𧬠YURI AI PRO")
|
| 45 |
+
st.caption("The smartest AI on the cloud, designed by you.")
|
| 46 |
st.markdown("---")
|
| 47 |
|
| 48 |
+
# --- API CONFIG ---
|
| 49 |
+
# Note: Agar aapne Secret variable set kiya hai toh niche wali line use karein
|
| 50 |
+
# GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
|
| 51 |
+
GROQ_API_KEY = "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"
|
| 52 |
|
|
|
|
| 53 |
if "messages" not in st.session_state:
|
| 54 |
st.session_state.messages = []
|
| 55 |
|
| 56 |
+
# Display Messages
|
| 57 |
for msg in st.session_state.messages:
|
| 58 |
with st.chat_message(msg["role"]):
|
| 59 |
st.markdown(msg["content"])
|
| 60 |
|
| 61 |
# User Input
|
| 62 |
+
if prompt := st.chat_input("Yuri se kuch bhi puchein..."):
|
|
|
|
| 63 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 64 |
with st.chat_message("user"):
|
| 65 |
st.markdown(prompt)
|
|
|
|
| 71 |
"Content-Type": "application/json"
|
| 72 |
}
|
| 73 |
payload = {
|
| 74 |
+
"model": "llama-3.3-70b-versatile",
|
| 75 |
"messages": [
|
| 76 |
+
{"role": "system", "content": "You are Yuri AI, a cool and stylish assistant. Use emojis and be very helpful."},
|
| 77 |
{"role": "user", "content": prompt}
|
| 78 |
],
|
| 79 |
+
"temperature": 0.8
|
| 80 |
}
|
| 81 |
|
| 82 |
with st.chat_message("assistant"):
|
|
|
|
| 87 |
st.markdown(answer)
|
| 88 |
st.session_state.messages.append({"role": "assistant", "content": answer})
|
| 89 |
else:
|
| 90 |
+
st.error("API Limit reached or Invalid Key!")
|
| 91 |
except Exception as e:
|
| 92 |
+
st.error(f"Error: {e}")
|
| 93 |
|