Spaces:
Running
Commit
•
e1a989a
1
Parent(s):
dc53314
feat: enter and format text
Browse files- .streamlit/config.toml +9 -0
- main.py +75 -0
.streamlit/config.toml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
primaryColor="#228b22"
|
3 |
+
backgroundColor="#fffffd"
|
4 |
+
secondaryBackgroundColor="#eeeeee"
|
5 |
+
textColor="#474539"
|
6 |
+
font="monospace"
|
7 |
+
|
8 |
+
[server]
|
9 |
+
headless=true
|
main.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
st.set_page_config(
|
4 |
+
page_title='👁️ semantic salience')
|
5 |
+
|
6 |
+
st.info(
|
7 |
+
'ℹ️ This tool is part of [a suite of experimental tools for thought](https://paulbricman.com/thoughtware) which incorporate AI primitives in knowledge work.')
|
8 |
+
|
9 |
+
hide_streamlit_style = '''
|
10 |
+
<style>
|
11 |
+
#MainMenu {visibility: hidden;}
|
12 |
+
footer {visibility: hidden;}
|
13 |
+
</style>
|
14 |
+
'''
|
15 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
16 |
+
|
17 |
+
st.title('👁️ semantic salience')
|
18 |
+
st.markdown('A fusion of artificial and organic attention.')
|
19 |
+
st.markdown('---')
|
20 |
+
|
21 |
+
query = st.text_input(
|
22 |
+
'driving query', help='Specify the overarching query which will drive the salience map.')
|
23 |
+
with st.expander('salience map settings', expanded=False):
|
24 |
+
pulsing = st.checkbox('pulsing effect', value=True,
|
25 |
+
help='Specify whether the salience map should be pulsing.')
|
26 |
+
duration = None
|
27 |
+
if pulsing:
|
28 |
+
duration = st.slider('pulse duration (seconds)', 0., 5., step=0.1, value=1.,
|
29 |
+
help='Specify how long the pulse should take')
|
30 |
+
focus = st.slider('focus strength', 0., 1., step=0.1, value=0.8,
|
31 |
+
help='Specify how sharp the focus of the salience map should be. Low focus means the salience is distributed more broadly across tokens. High focus means only a handful of tokens will be attended to. `softmax_temperature = 1 - focus`')
|
32 |
+
color = st.color_picker(
|
33 |
+
'halo color', help='Specify the color of the halo around tokens being attended to.')
|
34 |
+
|
35 |
+
with st.expander('text settings', expanded=False):
|
36 |
+
font_family = st.selectbox(
|
37 |
+
'font family', sorted(['Monospace', 'Times New Roman', 'Arial', 'Helvetica', 'Courier', 'Calibri', 'Georgia', 'Space Grotesk']))
|
38 |
+
font_size = st.slider('font size', 10, 20, step=1, value=14,
|
39 |
+
help='Specify how big the text should be.')
|
40 |
+
|
41 |
+
style = f'''
|
42 |
+
<style>
|
43 |
+
container {{
|
44 |
+
font-size: {font_size}pt;
|
45 |
+
font-family: {font_family};
|
46 |
+
text-align: justify; }}
|
47 |
+
|
48 |
+
.glow {{
|
49 |
+
color: black;
|
50 |
+
animation: glow {duration}s ease-in-out infinite alternate;
|
51 |
+
}}
|
52 |
+
|
53 |
+
@-webkit-keyframes glow {{
|
54 |
+
from {{
|
55 |
+
text-shadow: 0 0 10px #fff;
|
56 |
+
}}
|
57 |
+
|
58 |
+
to {{
|
59 |
+
text-shadow: 0 0 10px {color}, 0 0 20px {color}, 0 0 30px {color}, 0 0 40px {color}, 0 0 50px {color};
|
60 |
+
}}
|
61 |
+
}}
|
62 |
+
</style>'''
|
63 |
+
|
64 |
+
if 'content' not in st.session_state.keys() or st.session_state['content'] == None:
|
65 |
+
content = st.text_area('content', height=300)
|
66 |
+
if st.button('save'):
|
67 |
+
st.session_state['content'] = content
|
68 |
+
st.experimental_rerun()
|
69 |
+
else:
|
70 |
+
if st.button('reset'):
|
71 |
+
st.session_state['content'] = None
|
72 |
+
st.experimental_rerun()
|
73 |
+
content = style + '<container>' + ''.join(['<p>' + e +
|
74 |
+
'</p>' for e in st.session_state['content'].split('\n')]) + '</container>'
|
75 |
+
st.components.v1.html(content, scrolling=True, height=5000)
|