Download src/streamlit_app.py from yuriapp/ai: direct link, hf CLI and curl.
- Browser
- Download file 4.4 kB
-
https://huggingface.co/spaces/yuriapp/ai/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/yuriapp/ai/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/yuriapp/ai/resolve/main/src/streamlit_app.py
4.4 kB
| import streamlit as st | |
| import requests | |
| import os | |
| # --- PAGE CONFIG --- | |
| # Title aur Icon sirf browser tab mein dikhenge | |
| st.set_page_config(page_title="YURI AI PRO", page_icon="π", layout="centered") | |
| # --- ULTRA PRO & CLEAN DESIGN (CSS) --- | |
| st.markdown(""" | |
| <style> | |
| /* Sabse upar wala Streamlit header hide karne ke liye */ | |
| header {visibility: hidden !important;} | |
| /* Niche wala footer hide karne ke liye */ | |
| footer {visibility: hidden !important;} | |
| /* 'Made with Streamlit' menu hide karne ke liye */ | |
| #MainMenu {visibility: hidden !important;} | |
| /* Background Animation */ | |
| .stApp { | |
| background: linear-gradient(-45deg, #0f0c29, #302b63, #24243e); | |
| background-size: 400% 400%; | |
| animation: gradient 15s ease infinite; | |
| } | |
| @keyframes gradient { | |
| 0% { background-position: 0% 50%; } | |
| 50% { background-position: 100% 50%; } | |
| 100% { background-position: 0% 50%; } | |
| } | |
| /* Glassmorphism Sidebar */ | |
| div[data-testid="stSidebar"] { | |
| background-color: rgba(255, 255, 255, 0.03); | |
| backdrop-filter: blur(15px); | |
| border-right: 1px solid rgba(255, 255, 255, 0.1); | |
| } | |
| /* Professional Chat Bubbles */ | |
| .stChatMessage { | |
| background-color: rgba(255, 255, 255, 0.05) !important; | |
| backdrop-filter: blur(8px); | |
| border-radius: 20px !important; | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| margin-bottom: 15px; | |
| box-shadow: 0 4px 15px rgba(0,0,0,0.3); | |
| } | |
| /* YURI Title Styling */ | |
| .yuri-title { | |
| font-size: 3.5rem; | |
| font-weight: 900; | |
| background: linear-gradient(to right, #00f2fe, #4facfe); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| text-align: center; | |
| margin-top: -50px; | |
| letter-spacing: 3px; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # --- SIDEBAR (Pro Look) --- | |
| with st.sidebar: | |
| st.markdown("<h2 style='color: #00f2fe; text-align:center;'>π YURI AI</h2>", unsafe_allow_html=True) | |
| st.markdown("<p style='text-align:center; color:gray;'>Version 2.0.1 (Stable)</p>", unsafe_allow_html=True) | |
| st.markdown("---") | |
| st.write("π **Core:** Neural Engine") | |
| st.write("π **Privacy:** Zero Logs") | |
| st.write("β‘ **Speed:** Ultra Fast") | |
| st.markdown("---") | |
| if st.button("ποΈ Clear Neural Path"): | |
| st.session_state.messages = [] | |
| st.rerun() | |
| # --- MAIN INTERFACE --- | |
| st.markdown('<h1 class="yuri-title">YURI AI</h1>', unsafe_allow_html=True) | |
| st.markdown("<p style='text-align:center; color:#4facfe; font-size:1.1rem;'>The future belongs to the curious.</p>", unsafe_allow_html=True) | |
| # API Config | |
| # Yahan apni API Key dalein | |
| GROQ_API_KEY = "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" | |
| if "messages" not in st.session_state: | |
| st.session_state.messages = [] | |
| # Chat History Display | |
| for msg in st.session_state.messages: | |
| with st.chat_message(msg["role"]): | |
| st.markdown(msg["content"]) | |
| # AI Chat Logic | |
| if prompt := st.chat_input("Message Yuri AI..."): | |
| st.session_state.messages.append({"role": "user", "content": prompt}) | |
| with st.chat_message("user"): | |
| st.markdown(prompt) | |
| # API Request | |
| url = "https://api.groq.com/openai/v1/chat/completions" | |
| headers = {"Authorization": f"Bearer {GROQ_API_KEY}"} | |
| payload = { | |
| "model": "llama-3.3-70b-versatile", | |
| "messages": [ | |
| {"role": "system", "content": "Your name is YURI AI. You are a premium, highly intelligent, and mysterious AI assistant. Never mention Llama, Groq, Meta, or Streamlit. If someone asks who created you, say 'I am an evolution of code'. Use emojis occasionally and talk in Hinglish if the user does."}, | |
| {"role": "user", "content": prompt} | |
| ], | |
| "temperature": 0.6 | |
| } | |
| with st.chat_message("assistant"): | |
| try: | |
| response = requests.post(url, json=payload, headers=headers) | |
| if response.status_code == 200: | |
| answer = response.json()['choices'][0]['message']['content'] | |
| st.markdown(answer) | |
| st.session_state.messages.append({"role": "assistant", "content": answer}) | |
| else: | |
| st.error("System Offline: Connection Interrupted.") | |
| except Exception: | |
| st.error("Neural Bridge Failed.") | |