Chae commited on
Commit
9a7b741
·
1 Parent(s): 2e1f1d4

feat: got a minimal working anthropic-themed chatbot w/ gpt-oss-20b

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
.streamlit/config.toml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [server]
2
+ enableStaticServing = true
3
+
4
+ [[theme.fontFaces]]
5
+ family = "SpaceGrotesk"
6
+ url = "app/static/SpaceGrotesk-VariableFont_wght.ttf"
7
+
8
+ [[theme.fontFaces]]
9
+ family = "SpaceMono"
10
+ url = "app/static/SpaceMono-Bold.ttf"
11
+ style = "normal"
12
+ weight = 700
13
+
14
+ [[theme.fontFaces]]
15
+ family = "SpaceMono"
16
+ url = "app/static/SpaceMono-BoldItalic.ttf"
17
+ style = "italic"
18
+ weight = 700
19
+
20
+ [[theme.fontFaces]]
21
+ family = "SpaceMono"
22
+ url = "app/static/SpaceMono-Italic.ttf"
23
+ style = "italic"
24
+ weight = 400
25
+
26
+ [[theme.fontFaces]]
27
+ family = "SpaceMono"
28
+ url = "app/static/SpaceMono-Regular.ttf"
29
+ style = "normal"
30
+ weight = 400
31
+
32
+ [theme]
33
+ primaryColor = "#cb785c"
34
+ backgroundColor = "#fdfdf8"
35
+ secondaryBackgroundColor = "#ecebe3"
36
+ textColor = "#3d3a2a"
37
+ linkColor = "#3d3a2a"
38
+ borderColor = "#d3d2ca"
39
+ showWidgetBorder = true
40
+ baseRadius = "0.75rem"
41
+ buttonRadius = "full"
42
+ font = "SpaceGrotesk"
43
+ headingFontWeights = [600,500,500,500,500,500]
44
+ headingFontSizes = ["3rem", "2rem"]
45
+ codeFont = "SpaceMono"
46
+ codeFontSize = ".75rem"
47
+ codeBackgroundColor = "#ecebe4"
48
+ showSidebarBorder = true
49
+ chartCategoricalColors = ["#0ea5e9", "#059669", "#fbbf24"]
50
+
51
+ [theme.sidebar]
52
+ backgroundColor = "#f0f0ec"
53
+ secondaryBackgroundColor = "#ecebe3"
54
+ headingFontSizes = ["1.6rem", "1.4rem", "1.2rem"]
55
+ dataframeHeaderBackgroundColor = "#e4e4e0"
__init__.py ADDED
File without changes
__pycache__/cards.cpython-311.pyc ADDED
Binary file (454 Bytes). View file
 
backup/streamlit_app.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from huggingface_hub import InferenceClient
3
+ import os
4
+
5
+ # Page configuration with anthropic styling
6
+ st.title("💬 GPT-OSS-20B Chatbot")
7
+ st.markdown("*A clean, multi-turn chatbot powered by GPT-OSS-20B*")
8
+
9
+ # Initialize Hugging Face client
10
+ hf_token = os.getenv("HF_TOKEN")
11
+ # if not hf_token:
12
+ # st.error("Please set your HF_TOKEN environment variable.")
13
+ # st.stop()
14
+
15
+ client = InferenceClient(
16
+ model="openai/gpt-oss-20b",
17
+ token=hf_token
18
+ )
19
+
20
+ # Initialize chat history
21
+ if "messages" not in st.session_state:
22
+ st.session_state.messages = []
23
+
24
+ # Sidebar configuration with anthropic styling
25
+ with st.sidebar:
26
+ st.header("⚙️ Configuration")
27
+
28
+ # Model parameters
29
+ system_prompt = st.text_area(
30
+ "System message",
31
+ value="You are a helpful assistant.",
32
+ help="Define the AI assistant's behavior and personality"
33
+ )
34
+
35
+ st.subheader("Generation Parameters")
36
+ max_tokens = st.slider("Max new tokens", 1, 2048, 512)
37
+ temperature = st.slider("Temperature", 0.1, 2.0, 0.7)
38
+ top_p = st.slider("Top-p", 0.1, 1.0, 0.95)
39
+
40
+ # Chat management
41
+ st.divider()
42
+ if st.button("🗑️ Clear Chat History", use_container_width=True):
43
+ st.session_state.messages = []
44
+ st.rerun()
45
+
46
+ # Display chat stats
47
+ if st.session_state.messages:
48
+ st.caption(f"Messages in conversation: {len(st.session_state.messages)}")
49
+
50
+ # Main chat interface
51
+ st.subheader("Chat")
52
+
53
+ # Display chat history with improved formatting
54
+ for message in st.session_state.messages:
55
+ with st.chat_message(message["role"]):
56
+ st.markdown(message["content"])
57
+
58
+ # Chat input
59
+ if prompt := st.chat_input("Type your message here..."):
60
+ # Add user message to chat history
61
+ st.session_state.messages.append({"role": "user", "content": prompt})
62
+
63
+ # Display user message
64
+ with st.chat_message("user"):
65
+ st.markdown(prompt)
66
+
67
+ # Generate and display assistant response
68
+ with st.chat_message("assistant"):
69
+ with st.spinner("Thinking..."):
70
+ try:
71
+ # Prepare messages for API call
72
+ messages_for_api = [{"role": "system", "content": system_prompt}]
73
+ messages_for_api.extend(st.session_state.messages)
74
+
75
+ # Call Hugging Face API
76
+ response = client.chat_completion(
77
+ messages=messages_for_api,
78
+ max_tokens=max_tokens,
79
+ temperature=temperature,
80
+ top_p=top_p,
81
+ stream=False,
82
+ )
83
+
84
+ # Extract and display response
85
+ reply = response.choices[0].message["content"]
86
+ st.markdown(reply)
87
+
88
+ # Add assistant response to chat history
89
+ st.session_state.messages.append({"role": "assistant", "content": reply})
90
+
91
+ except Exception as e:
92
+ st.error(f"Error generating response: {str(e)}")
93
+ # Don't add the user message if there was an error
94
+ st.session_state.messages.pop()
95
+
96
+ # Footer
97
+ st.divider()
98
+ st.caption("Built with Streamlit • Powered by GPT-OSS-20B • Styled with Anthropic theme")
cards.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def chat_card():
4
+ st.page_link("chat.py", label="Chat", icon=":material/chat:")
5
+ # st.chat_message("user").write("Hello, world!")
6
+ # st.chat_message("assistant").write("Hello, user!")
7
+ # st.chat_input("Type something")
8
+
9
+ # def status_card():
10
+ # st.page_link("status.py", label="Status", icon=":material/error:")
11
+ # cols = st.columns(2)
12
+ # cols[0].error("Error")
13
+ # cols[0].warning("Warning")
14
+ # cols[1].info("Info")
15
+ # cols[1].success("Success")
16
+ # cols = st.columns(2)
17
+ # if cols[0].button("Toast!"):
18
+ # st.toast("Toast message", icon=":material/notifications:")
19
+ # if cols[1].button("Balloons!"):
20
+ # st.balloons()
chat.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # chat.py
2
+ import streamlit as st
3
+ from huggingface_hub import InferenceClient
4
+ import os
5
+ import json
6
+
7
+ st.header("In-place feedback demo")
8
+
9
+ # import the inference client
10
+ hf_token = os.getenv("HF_TOKEN")
11
+ client = InferenceClient(model="openai/gpt-oss-20b", token=hf_token)
12
+
13
+ #### Initialize chat history
14
+ if "messages" not in st.session_state:
15
+ st.session_state.messages = []
16
+
17
+ #### set basic parameters
18
+ # hard-coded for now but can be changed
19
+ max_tokens = 60000
20
+ temperature = 0.7
21
+ top_p = 0.95
22
+
23
+ if "chat_history" not in st.session_state:
24
+ st.session_state.chat_history = [{"role": "assistant", "content": "Ask me anything!"}]
25
+
26
+ # Display chat
27
+ for message in st.session_state.chat_history:
28
+ with st.chat_message(message["role"]):
29
+ st.markdown(message["content"])
30
+ if "reasoning" in message:
31
+ with st.expander("Show reasoning"):
32
+ st.markdown(message["reasoning"])
33
+
34
+ if prompt := st.chat_input("Send a message"):
35
+ # add message to chat history
36
+ st.session_state.chat_history.append({"role": "user", "content": prompt})
37
+ # show message
38
+ with st.chat_message("user"):
39
+ st.markdown(prompt) # for markdown of user text
40
+
41
+ # Prepare messages for API call
42
+ messages_for_api = [{"role": "system", "content": "You are a helpful assistant."}]
43
+ messages_for_api.extend(st.session_state.chat_history)
44
+
45
+ # Generate and display assistant response
46
+ with st.chat_message("assistant"):
47
+ with st.spinner("Thinking..."):
48
+ try:
49
+ # Call Hugging Face API
50
+ response = client.chat_completion(messages=messages_for_api,
51
+ max_tokens=max_tokens,
52
+ temperature=temperature,
53
+ top_p=top_p,
54
+ stream=False,
55
+ )
56
+
57
+ ######## debug #########
58
+ print("=== RAW RESPONSE ===")
59
+ print(json.dumps(response.__dict__, indent=2, default=str))
60
+
61
+ # show the response
62
+ reply = response.choices[0].message["content"]
63
+ st.markdown(reply)
64
+ print(reply)
65
+
66
+ reasoning = getattr(response.choices[0], "reasoning", None)
67
+ if reasoning:
68
+ with st.expander("Show reasoning"):
69
+ st.markdown(reasoning)
70
+
71
+ # Add assistant response to chat history
72
+ st.session_state.chat_history.append(
73
+ {"role": "assistant", "content": reply}
74
+ )
75
+
76
+ except Exception as e:
77
+ st.error(f"Error generating response: {str(e)}")
78
+ # Don't add the user message if there was an error
79
+ st.session_state.chat_history.pop()
80
+
layouts.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ @st.dialog("This is a dialog")
4
+ def dialog_function():
5
+ st.write("This is a dialog function.")
6
+ if st.button("Close"):
7
+ st.rerun(scope="app")
8
+
9
+ st.header("Layout elements")
10
+
11
+ a, b, c, d = st.tabs(["Tab A", "Tab B", "Tab C", "Tab D"])
12
+ with a:
13
+ st.write("This is the content of Tab A.")
14
+ with b:
15
+ st.write("This is the content of Tab B.")
16
+ with c:
17
+ st.write("This is the content of Tab C.")
18
+ with d:
19
+ st.write("This is the content of Tab D.")
20
+
21
+ st.subheader("Columns")
22
+ col0, col1, col2 = st.columns(3, border=True)
23
+ col0.write("This is the first column.")
24
+ col1.write("This is the second column.")
25
+ col2.write("This is the third column.")
26
+ st.expander("Expander").write("This is an expander")
27
+ col0, col1 = st.columns(2)
28
+ col0.popover("Popover").write("This is a popover")
29
+ if col1.button("Dialog"):
30
+ dialog_function()
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
 
1
  altair
2
- pandas
3
- streamlit
 
1
+ streamlit
2
+ huggingface_hub
3
  altair
4
+ pandas
 
src/streamlit_app.py DELETED
@@ -1,40 +0,0 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
- import streamlit as st
5
-
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/OFL-SpaceGrotesk.txt ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
static/OFL-SpaceMono.txt ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2016 The Space Mono Project Authors (https://github.com/googlefonts/spacemono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
static/SpaceGrotesk-SemiBold.ttf ADDED
Binary file (86.6 kB). View file
 
static/SpaceMono-Bold.ttf ADDED
Binary file (97.3 kB). View file
 
static/SpaceMono-Regular.ttf ADDED
Binary file (98.3 kB). View file
 
status.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.header("Status elements")
4
+
5
+ st.error("This is an error message.")
6
+ st.warning("This is a warning message.")
7
+ st.info("This is an info message.")
8
+ st.success("This is a success message.")
9
+
10
+ e = RuntimeError("This is an exception of type RuntimeError")
11
+ st.exception(e)
12
+
13
+ if st.button("Toast"):
14
+ st.toast("This is a toast message.")
15
+ st.button("Balloons", on_click=st.balloons)
16
+ st.button("Snow", on_click=st.snow)
streamlit_app.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # streamlit_app.py
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import numpy as np
5
+ from pathlib import Path
6
+
7
+ from cards import (
8
+ # widgets_card,
9
+ # text_card,
10
+ # dataframe_card,
11
+ # charts_card,
12
+ # media_card,
13
+ # layouts_card,
14
+ chat_card,
15
+ # status_card
16
+ )
17
+
18
+ if "init" not in st.session_state:
19
+ # st.session_state.chart_data = pd.DataFrame(
20
+ # np.random.randn(20, 3), columns=["a", "b", "c"]
21
+ # )
22
+ # st.session_state.map_data = pd.DataFrame(
23
+ # np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
24
+ # columns=["lat", "lon"],
25
+ # )
26
+ st.session_state.init = True
27
+
28
+
29
+ pages = [
30
+ # st.Page(
31
+ # "home.py",
32
+ # title="Home",
33
+ # icon=":material/home:"
34
+ # ),
35
+ # st.Page(
36
+ # "widgets.py",
37
+ # title="Widgets",
38
+ # icon=":material/widgets:"
39
+ # ),
40
+ # st.Page(
41
+ # "text.py",
42
+ # title="Text",
43
+ # icon=":material/article:"
44
+ # ),
45
+ # st.Page(
46
+ # "data.py",
47
+ # title="Data",
48
+ # icon=":material/table:"
49
+ # ),
50
+ # st.Page(
51
+ # "charts.py",
52
+ # title="Charts",
53
+ # icon=":material/insert_chart:"
54
+ # ),
55
+ # st.Page(
56
+ # "media.py",
57
+ # title="Media",
58
+ # icon=":material/image:"
59
+ # ),
60
+ # st.Page(
61
+ # "layouts.py",
62
+ # title="Layouts",
63
+ # icon=":material/dashboard:"
64
+ # ),
65
+ st.Page(
66
+ "chat.py",
67
+ title="Chat",
68
+ icon=":material/chat:"
69
+ ),
70
+ # st.Page(
71
+ # "status.py",
72
+ # title="Status",
73
+ # icon=":material/error:"
74
+ # ),
75
+ ]
76
+
77
+ page = st.navigation(pages)
78
+ page.run()
79
+
80
+ with st.sidebar.container(height=310):
81
+ if page.title == "Chat":
82
+ chat_card()
83
+ else:
84
+ st.page_link("home.py", label="Home", icon=":material/home:")
85
+ st.write("Welcome to the home page!")
86
+
87
+ st.sidebar.caption(
88
+ "This app uses [Space Grotesk](https://fonts.google.com/specimen/Space+Grotesk) "
89
+ "and [Space Mono](https://fonts.google.com/specimen/Space+Mono) fonts."
90
+ )
text.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.header("Text elements")
4
+ cols = st.columns(2)
5
+
6
+ with cols[0].container(border=True):
7
+ st.title("Title")
8
+ st.markdown("*Lorem ipsum*")
9
+ st.header("Header")
10
+ st.markdown("*Lorem ipsum*")
11
+ st.subheader("Subheader")
12
+ st.markdown("*Lorem ipsum*")
13
+
14
+ with cols[1]:
15
+ st.markdown(r"Markdown: **bold** *italic* ~strikethrough~ [link](https://streamlit.io) `code` $\int_a^b f(x)$ 🐶 :cat: :material/home: :streamlit: <- -> <-> -- >= <= ~= ")
16
+ st.markdown(
17
+ "Text colors:\n"
18
+ ":blue[blue] :green[green] :orange[orange] :red[red] :violet[violet] "
19
+ ":gray[gray] :rainbow[rainbow] :primary[primary]\n\n"
20
+ ":blue-background[blue] :green-background[green] :orange-background[orange] "
21
+ ":red-background[red] :violet-background[violet] :gray-background[gray] "
22
+ ":rainbow-background[rainbow] :primary-background[primary]\n\n"
23
+ ":blue-background[:blue[blue]] :green-background[:green[green]] "
24
+ ":orange-background[:orange[orange]] :red-background[:red[red]] "
25
+ ":violet-background[:violet[violet]] :gray-background[:gray[gray]] "
26
+ ":rainbow-background[:rainbow[rainbow]] :primary-background[:primary[primary]]"
27
+ )
28
+ st.caption("Caption")
29
+ st.badge("Badge", icon=":material/star:", color="primary")
30
+
31
+ st.divider()
32
+ st.code (
33
+ "import streamlit as st\n"
34
+ "\n"
35
+ 'st.write("Hello, world!")\n'
36
+ )
37
+ st.help(st.write)
widgets.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.header("Widgets")
4
+ tabs = st.tabs(["Buttons", "Selections", "Numeric", "Text", "Media"])
5
+ with tabs[0]:
6
+ cols = st.columns(3)
7
+ cols[0].button("Primary button", type="primary")
8
+ cols[1].button("Secondary button", type="secondary")
9
+ cols[2].button("Tertiary button", type="tertiary")
10
+ with st.form(key="button_form"):
11
+ st.subheader("Form")
12
+ st.text_input("Text input")
13
+ st.form_submit_button("Submit button")
14
+ st.link_button("Link button", url="https://streamlit.io", icon=":material/open_in_new:")
15
+ st.page_link("widgets.py", label="Page link (this page)", icon=":material/my_location:")
16
+ st.page_link("text.py", label="Page link (next page)", icon=":material/skip_next:")
17
+
18
+ with tabs[1]:
19
+ cols = st.columns(2)
20
+ with cols[0]:
21
+ st.checkbox("Checkbox")
22
+ st.selectbox("Selectbox", options=["A", "B", "C"])
23
+ st.pills("Pills", options=["A", "B", "C"])
24
+ st.select_slider("Select slider", options=["A", "B", "C"])
25
+
26
+ with cols[1]:
27
+ st.toggle("Toggle")
28
+ st.radio("Radio", options=["A", "B", "C"], horizontal=True)
29
+ st.segmented_control("Segmented control", options=["A", "B", "C"])
30
+ st.caption("Feedback")
31
+ st.feedback("faces")
32
+
33
+ st.multiselect("Multiselect", options=["A", "B", "C"])
34
+
35
+ with tabs[2]:
36
+ st.number_input("Number input")
37
+ st.slider("Slider")
38
+ st.date_input("Date input")
39
+ st.time_input("Time input")
40
+
41
+ with tabs[3]:
42
+ cols = st.columns(2)
43
+ cols[0].text_input("Text input")
44
+ cols[1].html("<div style='height:.75em'>&nbsp;</div>")
45
+ cols[1].chat_input("Type something")
46
+
47
+ st.text_area("Text area")
48
+
49
+ with tabs[4]:
50
+ st.file_uploader("File input")
51
+ st.audio_input("Audio input")
52
+ st.camera_input("Camera input")