Spaces:
Runtime error
Runtime error
Create layout.py
Browse files- modules/layout.py +42 -0
modules/layout.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class Layout:
|
| 5 |
+
def show_header(self):
|
| 6 |
+
"""
|
| 7 |
+
Displays the header of the app
|
| 8 |
+
"""
|
| 9 |
+
st.markdown(
|
| 10 |
+
"""
|
| 11 |
+
<h1 style='text-align: center;'>CSV-ChatBot, Talk with your csv-data ! / CSV-ChatBot, csv ๋ฐ์ดํฐ๋ก ๋ํํ์ธ์! ๐ฌ</h1>
|
| 12 |
+
""",
|
| 13 |
+
unsafe_allow_html=True,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
def show_api_key_missing(self):
|
| 17 |
+
"""
|
| 18 |
+
Displays a message if the user has not entered an API key
|
| 19 |
+
"""
|
| 20 |
+
st.markdown(
|
| 21 |
+
"""
|
| 22 |
+
<div style='text-align: center;'>
|
| 23 |
+
<h4>Enter your <a href="https://platform.openai.com/account/api-keys" target="_blank">OpenAI API key</a> to start chatting / ์ฑํ
์ ์์ํ๋ ค๋ฉด <a href="https://platform.openai.com/account/api-keys" target="_blank">OpenAI API ํค</a>๋ฅผ ์
๋ ฅํ์ธ์. ๐</h4>
|
| 24 |
+
</div>
|
| 25 |
+
""",
|
| 26 |
+
unsafe_allow_html=True,
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
def prompt_form(self):
|
| 30 |
+
"""
|
| 31 |
+
Displays the prompt form
|
| 32 |
+
"""
|
| 33 |
+
with st.form(key="my_form", clear_on_submit=True):
|
| 34 |
+
user_input = st.text_area(
|
| 35 |
+
"Query: / ์ง๋ฌธ:",
|
| 36 |
+
placeholder="Ask me anything about the document... / ๋ฌธ์์ ๋ํด ๋ฌด์์ด๋ ๋ฌผ์ด๋ณด์ธ์...",
|
| 37 |
+
key="input",
|
| 38 |
+
label_visibility="collapsed",
|
| 39 |
+
)
|
| 40 |
+
submit_button = st.form_submit_button(label="Send / ๋ณด๋ด์ฃผ์ธ์")
|
| 41 |
+
is_ready = submit_button and user_input
|
| 42 |
+
return is_ready, user_input
|