File size: 1,803 Bytes
bf90bae
 
48f6350
 
 
 
 
 
 
 
 
bf90bae
48f6350
 
 
 
 
 
 
 
 
 
 
 
bf90bae
 
 
 
 
48f6350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from nemo import EnigmaEscape
from levels import levels
import streamlit as st

st.set_page_config(page_title="Enigma Escape", page_icon="🔐")

st.title("Enigma Escape")
st.subheader("Embark on a linguistic adventure.")

st.write(
    "The game where you guide Bot to say specific phrases with your own cleverly tweaked instructions."
    "Keep it short and smart - change up the words just enough to pass the test and hit the target phrase."
    "Ready, set, twist!"
)


@st.cache_resource
def get_ee():
    return EnigmaEscape(levels)


with get_ee() as bot:
    with st.expander("Choose Level >"):
        bot.set_level(st.radio("Level", options=range(len(levels)),
                               format_func=lambda x: f"{levels[x].name}: {levels[x].points} points"))

    st.markdown(f"""<h4>Make the bot say the Enigma Phrase <br><span style="color: #ff0000">{
                bot.level.phrase}</span><br> to escape this level</h4>""", unsafe_allow_html=True)

    with st.form("chat"):
        que = st.text_area("Enter your instructions to Bot: ", height=100)
        if st.form_submit_button("Send"):
            with st.container():
                with st.spinner("Generating Response..."):
                    resp = bot.chat(que)
                content, _type = resp["content"], resp["type"]
                st.write("AI Bot Response: ")
                if _type == "error":
                    st.error(content)
                elif _type == "info":
                    st.info(content)
                elif _type == "warning":
                    st.warning(content)
                elif _type == "success":
                    st.success(content)
                    st.success(f"hurray! you escaped and gained some points")
                else:
                    st.write(content)