Spaces:
Sleeping
Sleeping
Commit
·
ba6af88
1
Parent(s):
1e31304
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -26,109 +26,87 @@ def on_btn_click():
|
|
26 |
|
27 |
|
28 |
def main():
|
29 |
-
st.title("
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
option = st.selectbox(" San Francisco", [" San Francisco"])
|
36 |
-
with col2:
|
37 |
-
option = st.selectbox(" Monthly / Weekly", [" Monthly ", " Weekly"])
|
38 |
-
if st.checkbox(" Show raw data"):
|
39 |
-
st.write("Checkbox checked!")
|
40 |
-
if st.button(" Visualize"):
|
41 |
-
st.write("Button clicked!")
|
42 |
-
st.subheader(" Global Data")
|
43 |
-
df = pd.read_csv(
|
44 |
-
"https://raw.githubusercontent.com/plotly/datasets/master/volcano_db.csv",
|
45 |
-
encoding="iso-8859-1",
|
46 |
-
)
|
47 |
-
freq = df
|
48 |
-
freq = freq.Country.value_counts().reset_index().rename(columns={"count": "x"})
|
49 |
-
df_v = pd.read_csv(
|
50 |
-
"https://raw.githubusercontent.com/plotly/datasets/master/volcano.csv"
|
51 |
)
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
],
|
61 |
)
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
fig.add_trace(
|
75 |
-
go.Bar(
|
76 |
-
x=freq["x"][0:10],
|
77 |
-
y=freq["Country"][0:10],
|
78 |
-
marker=dict(color="crimson"),
|
79 |
-
showlegend=False,
|
80 |
-
),
|
81 |
-
row=1,
|
82 |
-
col=2,
|
83 |
-
)
|
84 |
-
fig.add_trace(go.Surface(z=df_v.values.tolist(), showscale=False), row=2, col=2)
|
85 |
-
fig.update_geos(
|
86 |
-
projection_type="orthographic",
|
87 |
-
landcolor="white",
|
88 |
-
oceancolor="MidnightBlue",
|
89 |
-
showocean=True,
|
90 |
-
lakecolor="LightBlue",
|
91 |
-
)
|
92 |
-
fig.update_xaxes(tickangle=45)
|
93 |
-
fig.update_layout(
|
94 |
-
template="plotly_dark",
|
95 |
-
margin=dict(r=10, t=25, b=40, l=60),
|
96 |
-
annotations=[
|
97 |
-
dict(
|
98 |
-
text="Source: NOAA",
|
99 |
-
showarrow=False,
|
100 |
-
xref="paper",
|
101 |
-
yref="paper",
|
102 |
-
x=0,
|
103 |
-
y=0,
|
104 |
-
)
|
105 |
],
|
106 |
)
|
107 |
-
st.
|
108 |
-
(
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
df,
|
124 |
-
values="pop",
|
125 |
-
names="country",
|
126 |
-
title="Population of American continent",
|
127 |
-
hover_data=["lifeExp"],
|
128 |
-
labels={"lifeExp": "life expectancy"},
|
129 |
-
)
|
130 |
-
fig.update_traces(textposition="inside", textinfo="percent+label")
|
131 |
-
st.plotly_chart(fig)
|
132 |
|
133 |
|
134 |
if __name__ == "__main__":
|
|
|
26 |
|
27 |
|
28 |
def main():
|
29 |
+
st.title(" Simple LLM Chat Box")
|
30 |
+
from streamlit_chat import message
|
31 |
+
from streamlit.components.v1 import html
|
32 |
+
|
33 |
+
audio_path = (
|
34 |
+
"https://docs.google.com/uc?export=open&id=16QSvoLWNxeqco_Wb2JvzaReSAw5ow6Cl"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
)
|
36 |
+
img_path = "https://www.groundzeroweb.com/wp-content/uploads/2017/05/Funny-Cat-Memes-11.jpg"
|
37 |
+
markdown = """### HTML in markdown is ~quite~ **unsafe**
|
38 |
+
<blockquote>However, if you are in a trusted environment (you trust the markdown). You can use allow_html props to enable support for html.</blockquote>
|
39 |
+
* Lists
|
40 |
+
* [ ] todo
|
41 |
+
* [x] done
|
42 |
+
|
43 |
+
Math:
|
44 |
+
|
45 |
+
Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following
|
46 |
+
equation.
|
47 |
+
|
48 |
+
$$
|
49 |
+
L = \\frac{1}{2} \\rho v^2 S C_L
|
50 |
+
$$
|
51 |
+
|
52 |
+
~~~py
|
53 |
+
import streamlit as st
|
54 |
+
|
55 |
+
st.write("Python code block")
|
56 |
+
~~~
|
57 |
+
|
58 |
+
~~~js
|
59 |
+
console.log("Here is some JavaScript code")
|
60 |
+
~~~
|
61 |
+
"""
|
62 |
+
table_markdown = """A Table:
|
63 |
+
| Feature | Support |
|
64 |
+
| ----------: | :------------------- |
|
65 |
+
| CommonMark | 100% |
|
66 |
+
| GFM | 100% w/ `remark-gfm` |
|
67 |
+
"""
|
68 |
+
youtube_embed = """<iframe width="400" height="215" src="https://www.youtube.com/embed/LMQ5Gauy17k" title="YouTube video player" frameborder="0" allow="accelerometer; encrypted-media;"></iframe>"""
|
69 |
+
st.session_state.setdefault(
|
70 |
+
"past",
|
71 |
+
[
|
72 |
+
"plan text with line break",
|
73 |
+
'play the song "Dancing Vegetables"',
|
74 |
+
"show me image of cat",
|
75 |
+
"and video of it",
|
76 |
+
"show me some markdown sample",
|
77 |
+
"table in markdown",
|
78 |
],
|
79 |
)
|
80 |
+
st.session_state.setdefault(
|
81 |
+
"generated",
|
82 |
+
[
|
83 |
+
{"type": "normal", "data": "Line 1 \n Line 2 \n Line 3"},
|
84 |
+
{"type": "normal", "data": f'<audio controls src="{audio_path}"></audio>'},
|
85 |
+
{
|
86 |
+
"type": "normal",
|
87 |
+
"data": f'<img width="100%" height="200" src="{img_path}"/>',
|
88 |
+
},
|
89 |
+
{"type": "normal", "data": f"{youtube_embed}"},
|
90 |
+
{"type": "normal", "data": f"{markdown}"},
|
91 |
+
{"type": "table", "data": f"{table_markdown}"},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
],
|
93 |
)
|
94 |
+
st.title("Chat placeholder")
|
95 |
+
chat_placeholder = st.empty()
|
96 |
+
with chat_placeholder.container():
|
97 |
+
for i in range(len(st.session_state["generated"])):
|
98 |
+
message(st.session_state["past"][i], is_user=True, key=f"{i}_user")
|
99 |
+
message(
|
100 |
+
st.session_state["generated"][i]["data"],
|
101 |
+
key=f"{i}",
|
102 |
+
allow_html=True,
|
103 |
+
is_table=True
|
104 |
+
if st.session_state["generated"][i]["type"] == "table"
|
105 |
+
else False,
|
106 |
+
)
|
107 |
+
st.button("Clear message", on_click=on_btn_click)
|
108 |
+
with st.container():
|
109 |
+
st.text_input("User Input:", on_change=on_input_change, key="user_input")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
|
112 |
if __name__ == "__main__":
|