-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
34 lines (27 loc) · 1.37 KB
/
app.py
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
import streamlit as st
from components import st_backend
st.set_page_config(page_title="Word Power AI", layout="centered")
K = st_backend.Backend()
header = st.container()
body = st.container()
with st.sidebar:
pat = st.text_input('Enter Personal Access Token(Clarifai):', type="password")
prompt = st.text_input('Enter a topic:')
st.button('Generate Story', on_click = K.execute_workflow, args=(pat,prompt))
st.info('Get Personal Access Token from the Clarifai portal.', icon="ℹ️")
with header:
st.markdown("<h1 style='text-align: center;'>Word Power AI</h1>", unsafe_allow_html=True)
st.subheader('', divider='gray')
with body:
st.image(st.session_state['image'], use_column_width=True)
st.audio(st.session_state['audio'], format="audio/mp3")
st.subheader('', divider='gray')
st.subheader('Story:')
st.write(st.session_state['story'] if st.session_state['story_state'] else st.session_state['story_blanks'])
options = st.multiselect('Select answers in order of blanks:', st.session_state['answer_sorted'], key="multiselect")
st.write('You selected:', dict(enumerate(options,start=1)))
submit, reset, *_ = st.columns(7)
with submit:
st.button('Submit', on_click = K.match_answer, args=(options, st.session_state['answer']))
with reset:
st.button('Reset', on_click = K.reset_story)