Spaces:
Sleeping
Sleeping
Commit
·
c6c1795
1
Parent(s):
58d3709
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -26,59 +26,87 @@ def on_btn_click():
|
|
26 |
|
27 |
|
28 |
def main():
|
29 |
-
st.title("
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
33 |
)
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
{
|
45 |
-
"
|
46 |
-
"
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
st.json(data)
|
53 |
-
st.title(" Forecast")
|
54 |
-
(
|
55 |
-
col1,
|
56 |
-
col2,
|
57 |
-
) = st.columns(2)
|
58 |
-
with col1:
|
59 |
-
st.line_chart(
|
60 |
-
pd.DataFrame(
|
61 |
-
{
|
62 |
-
"Apple": yf.download("AAPL", start="2023-01-01", end="2023-07-31")[
|
63 |
-
"Adj Close"
|
64 |
-
],
|
65 |
-
"Google": yf.download(
|
66 |
-
"GOOGL", start="2023-01-01", end="2023-07-31"
|
67 |
-
)["Adj Close"],
|
68 |
-
"Microsoft": yf.download(
|
69 |
-
"MSFT", start="2023-01-01", end="2023-07-31"
|
70 |
-
)["Adj Close"],
|
71 |
-
}
|
72 |
-
)
|
73 |
-
)
|
74 |
-
with col2:
|
75 |
-
data = pd.DataFrame(
|
76 |
-
{"X": [1, 2, 3, 4, 5], "Y1": [10, 16, 8, 14, 12], "Y2": [5, 8, 3, 6, 7]}
|
77 |
-
)
|
78 |
-
st.area_chart(data)
|
79 |
-
st.bar_chart(
|
80 |
-
pd.DataFrame(np.random.randn(20, 3), columns=["Apple", "Banana", "Cherry"])
|
81 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
|
84 |
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__":
|