sparkhelix-ai / src /streamlit_app.py
CodeFlame's picture
Update src/streamlit_app.py
a67ee2c verified
Raw
History Blame Contribute Delete
2.22 kB
import streamlit as st
import streamlit.components.v1 as components
from huggingface_hub import InferenceClient
# Force layout optimization
st.set_page_config(page_title="SparkHelix AI", page_icon="🧬", layout="wide")
# Hide standard Streamlit header frameworks
st.markdown("""
<style>
#MainMenu, footer, header {visibility: hidden;}
div.block-container {padding: 0rem !important; max-width: 100% !important;}
[data-testid="stSidebar"] {background-color: #0d1017 !important;}
</style>
""", unsafe_allow_html=True)
# Initialize Session Logs
if "messages" not in st.session_state:
st.session_state.messages = [{"role": "assistant", "content": "Hello! I am SparkHelix. How can I help you discover or build today?"}]
# =====================================================================
# 🎨 STREAMLINED COPILOT ARCHITECTURE
# =====================================================================
# Build clean container styles using native markdown components
st.title("🧬 SparkHelix Copilot")
st.caption("Next-gen companion agent connected to web engines and inference clusters.")
st.markdown("---")
# Render elements using clear blocks
for msg in st.session_state.messages:
if msg["role"] == "assistant":
with st.chat_message("assistant", avatar="🧬"):
st.markdown(f"**SparkHelix**\n\n{msg['content']}")
else:
with st.chat_message("user"):
st.markdown(msg['content'])
# Pinned Interactive Chat Box
user_input = st.chat_input("Ask SparkHelix anything...")
if user_input:
st.session_state.messages.append({"role": "user", "content": user_input})
try:
client = InferenceClient()
response = client.chat.completions.create(
model="Qwen/Qwen2.5-7B-Instruct",
messages=[{"role": "user", "content": user_input}],
max_tokens=512,
temperature=0.4
)
ai_reply = response.choices[0].message.content
st.session_state.messages.append({"role": "assistant", "content": ai_reply})
except Exception as e:
st.session_state.messages.append({"role": "assistant", "content": f"System Alert: Routing congestion. Details: {e}"})
st.rerun()