Spaces:
Running
Running
import streamlit as st | |
import requests | |
import os | |
tok=os.getenv("TOK") | |
def InitSession(): | |
if "username" not in st.session_state: | |
st.session_state.username="" | |
if "projectname" not in st.session_state: | |
st.session_state.projectname="" | |
InitSession() | |
def APP(): | |
col1,col2=st.columns(2) | |
with col1: | |
#st.title("newMATTER") | |
st.markdown(""" | |
<h2>new <i style='color:red'>MATTER</i> </h2> | |
""",unsafe_allow_html=True) | |
with col2: | |
st.image("https://pub-e4d20ff4ef334a2894d440ac56d680db.r2.dev/flask.gif",width=190) | |
tab1, tab2, tab3 = st.tabs(["PROTEIN ENGINEERING LAB", "EXECUTED OPERATIONS", "LAB OUTPUT"]) | |
def SHOWTABS(): | |
st.markdown(""" | |
<style> | |
@keyframes blink { | |
0% { opacity: 1; } | |
50% { opacity: 0; } | |
100% { opacity: 1; } | |
} | |
.blinking-text { | |
animation: blink 2s infinite; | |
font-size: 20px; | |
font-weight: bold; | |
color: red; | |
} | |
</style> | |
""", unsafe_allow_html=True) | |
st.markdown('<div class="blinking-text"> CAUTION ! </div>', unsafe_allow_html=True) | |
with tab1: | |
with st.form("bio",border=False): | |
uid=None | |
project_name=None | |
with st.expander("setup",icon=":material/settings:"): | |
uid=st.text_input("enter username") | |
project_name=st.text_input("enter project name ") | |
if not uid or not project_name: | |
st.markdown(":orange-badge[⚠️ Set Username and Projectname]") | |
else: | |
bio_input = st.text_area( | |
"Protein Engineering Query", | |
placeholder="Type your query here." | |
) | |
execute_button=st.form_submit_button("execute") | |
if execute_button: | |
st.session_state.projectname =project_name | |
st.session_state.username=uid | |
payload={ | |
"uid":uid, | |
"pid":project_name | |
"high_level_bio_query":bio_input | |
} | |
response=requests.post("https://thexforce-combat-backend.hf.space/bio_context_language_plan",json=payload,headers={ | |
"Content-Type":"application/json", | |
"Authorization":f"Bearer {tok}" | |
}) | |
plan_response=response.json() | |
if plan_response.get("status")=="active": | |
st.code(f"> operation execution successfull", language="rust") | |
st.success("Task completed!") | |
else: | |
st.warning(">>>Error") | |
with tab2: | |
st.markdown("### newMATTER Bio Lab Operations") | |
response=requests.get(f"https://thexforce-combat-backend.hf.space/user/operations/{user_id}",headers={ | |
"Content-Type":"application/json", | |
"Authorization":f"Bearer {tok}" | |
}) | |
useroperations_json=response.json() | |
with st.expander("operations"): | |
st.json(useroperations_json) | |
with tab3: | |
st.markdown("### newMATTER Bio Lab Outputs") | |
SHOWTABS() |