Spaces:
Sleeping
Sleeping
Praveen998
commited on
Commit
·
df9740e
1
Parent(s):
a058629
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -26,136 +26,87 @@ def on_btn_click():
|
|
26 |
|
27 |
|
28 |
def main():
|
29 |
-
st.
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
)
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
{
|
72 |
-
"
|
73 |
-
"
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
pd.DataFrame(
|
80 |
-
{
|
81 |
-
"Apple": yf.download("AAPL", start="2023-01-01", end="2023-07-31")[
|
82 |
-
"Adj Close"
|
83 |
-
],
|
84 |
-
"Google": yf.download(
|
85 |
-
"GOOGL", start="2023-01-01", end="2023-07-31"
|
86 |
-
)["Adj Close"],
|
87 |
-
"Microsoft": yf.download(
|
88 |
-
"MSFT", start="2023-01-01", end="2023-07-31"
|
89 |
-
)["Adj Close"],
|
90 |
-
}
|
91 |
-
)
|
92 |
-
)
|
93 |
-
(
|
94 |
-
col1,
|
95 |
-
col2,
|
96 |
-
) = st.columns(2)
|
97 |
-
with col1:
|
98 |
-
data = pd.DataFrame(
|
99 |
-
{"X": [1, 2, 3, 4, 5], "Y1": [10, 16, 8, 14, 12], "Y2": [5, 8, 3, 6, 7]}
|
100 |
-
)
|
101 |
-
st.area_chart(data)
|
102 |
-
with col2:
|
103 |
-
st.bar_chart(
|
104 |
-
pd.DataFrame(np.random.randn(20, 3), columns=["Apple", "Banana", "Cherry"])
|
105 |
-
)
|
106 |
-
(
|
107 |
-
col1,
|
108 |
-
col2,
|
109 |
-
) = st.columns(2)
|
110 |
-
with col1:
|
111 |
-
st.write("Hello, world!")
|
112 |
-
with col2:
|
113 |
-
df = px.data.gapminder().query("year == 2007").query("continent == 'Americas'")
|
114 |
-
fig = px.pie(
|
115 |
-
df,
|
116 |
-
values="pop",
|
117 |
-
names="country",
|
118 |
-
title="Population of American continent",
|
119 |
-
hover_data=["lifeExp"],
|
120 |
-
labels={"lifeExp": "life expectancy"},
|
121 |
-
)
|
122 |
-
fig.update_traces(textposition="inside", textinfo="percent+label")
|
123 |
-
st.plotly_chart(fig)
|
124 |
-
source = vds.cars()
|
125 |
-
chart = {
|
126 |
-
"mark": "point",
|
127 |
-
"encoding": {
|
128 |
-
"x": {"field": "Horsepower", "type": "quantitative"},
|
129 |
-
"y": {"field": "Miles_per_Gallon", "type": "quantitative"},
|
130 |
-
"color": {"field": "Origin", "type": "nominal"},
|
131 |
-
"shape": {"field": "Origin", "type": "nominal"},
|
132 |
-
},
|
133 |
-
}
|
134 |
-
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Vega-Lite native theme"])
|
135 |
-
with tab1:
|
136 |
-
st.vega_lite_chart(source, chart, theme="streamlit", use_container_width=True)
|
137 |
-
with tab2:
|
138 |
-
st.vega_lite_chart(source, chart, theme=None, use_container_width=True)
|
139 |
-
(
|
140 |
-
col1,
|
141 |
-
col2,
|
142 |
-
) = st.columns(2)
|
143 |
-
with col1:
|
144 |
-
st.video("https://www.youtube.com/watch?v=50hVvC7gMR8&t=5s", format="video/mp4")
|
145 |
-
with col2:
|
146 |
-
st.image(
|
147 |
-
"https://assets-global.website-files.com/59e16042ec229e00016d3a66/6441d5f76d21e1e4dee9ffa2_Gen%20AI%20blog_Blog%20hero.png",
|
148 |
-
caption="Image Caption",
|
149 |
-
)
|
150 |
-
st.plotly_chart(
|
151 |
-
ff.create_distplot(
|
152 |
-
[np.random.randn(200) - 2, np.random.randn(200), np.random.randn(200) + 2],
|
153 |
-
["Negative Shift", "Normal", "Positive Shift"],
|
154 |
-
bin_size=[0.1, 0.25, 0.5],
|
155 |
-
),
|
156 |
-
use_container_width=True,
|
157 |
)
|
158 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
|
161 |
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__":
|