Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -129,8 +129,8 @@ def get_study_tip_for_keyword(keyword, api_key):
|
|
129 |
# 5. Streamlit UI
|
130 |
# -------------------------------
|
131 |
def main():
|
132 |
-
st.set_page_config(page_title="
|
133 |
-
st.title("
|
134 |
|
135 |
api_key = st.text_input("๐ Upstage API Key", type="password")
|
136 |
uploaded_file = st.file_uploader("๐ ๋ฌธ์ ์ด๋ฏธ์ง ์
๋ก๋", type=["pdf", "png", "jpg", "jpeg"])
|
@@ -153,17 +153,24 @@ def main():
|
|
153 |
st.session_state.html_text = html_text
|
154 |
st.success("๋ฌธ์ ํ์ฑ ์ฑ๊ณต โ
")
|
155 |
|
156 |
-
# ๋ฌธ์๊ฐ ์ค๋น๋ ๊ฒฝ์ฐ โ ์ข์ฐ ๋ ์ด์์ ์์
|
157 |
if st.session_state.html_text:
|
158 |
-
left_col, right_col = st.columns([1, 2])
|
159 |
|
160 |
with left_col:
|
161 |
-
st.image(uploaded_file, caption="๐ผ๏ธ
|
162 |
|
163 |
with right_col:
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
st.subheader("โ ๊ถ๊ธํ ๋ด์ฉ์ ์ง๋ฌธํด๋ณด์ธ์")
|
165 |
user_question = st.text_input("์ง๋ฌธ์ ์
๋ ฅํ๊ณ ์๋ ๋ฒํผ์ ๋๋ฌ๋ณด์ธ์", key="question_input")
|
166 |
|
|
|
|
|
167 |
if st.button("๐ฌ Solar์๊ฒ ๋ฌผ์ด๋ณด๊ธฐ") and user_question:
|
168 |
with st.spinner("Solar ์ ์๋์ด ๋ต๋ณ ์ค์
๋๋ค..."):
|
169 |
answer, history, err = chat_with_solar_document(
|
@@ -179,19 +186,21 @@ def main():
|
|
179 |
st.chat_message("user").write(user_question)
|
180 |
st.chat_message("assistant").write(answer)
|
181 |
|
182 |
-
#
|
|
|
|
|
183 |
st.session_state.keywords = get_recommended_keywords(
|
184 |
st.session_state.html_text,
|
185 |
user_question,
|
186 |
api_key
|
187 |
)
|
188 |
|
189 |
-
# ์ด์ ๋ํ
|
190 |
-
for user, bot in
|
191 |
st.chat_message("user").write(user)
|
192 |
st.chat_message("assistant").write(bot)
|
193 |
|
194 |
-
#
|
195 |
if st.session_state.keywords:
|
196 |
st.markdown("### ๐ ์ถ์ฒ ๊ณต๋ถ ํค์๋")
|
197 |
st.markdown(
|
@@ -210,6 +219,10 @@ def main():
|
|
210 |
|
211 |
st.markdown("</div>", unsafe_allow_html=True)
|
212 |
|
|
|
|
|
|
|
213 |
# ์คํ
|
214 |
if __name__ == "__main__":
|
215 |
main()
|
|
|
|
129 |
# 5. Streamlit UI
|
130 |
# -------------------------------
|
131 |
def main():
|
132 |
+
st.set_page_config(page_title="AI ๊ณต๋ถ ๋ฉํ ", layout="wide")
|
133 |
+
st.title("๐ฉโ๐ซ Solar Study Mentor")
|
134 |
|
135 |
api_key = st.text_input("๐ Upstage API Key", type="password")
|
136 |
uploaded_file = st.file_uploader("๐ ๋ฌธ์ ์ด๋ฏธ์ง ์
๋ก๋", type=["pdf", "png", "jpg", "jpeg"])
|
|
|
153 |
st.session_state.html_text = html_text
|
154 |
st.success("๋ฌธ์ ํ์ฑ ์ฑ๊ณต โ
")
|
155 |
|
|
|
156 |
if st.session_state.html_text:
|
157 |
+
left_col, right_col = st.columns([1, 2], gap="large")
|
158 |
|
159 |
with left_col:
|
160 |
+
st.image(uploaded_file, caption="๐ผ๏ธ ๋ฌธ์ ์ด๋ฏธ์ง", use_container_width=True)
|
161 |
|
162 |
with right_col:
|
163 |
+
# ์คํฌ๋กค ๊ฐ๋ฅํ ์ค๋ฅธ์ชฝ ์ ์ฒด ๋ฐ์ค
|
164 |
+
st.markdown(
|
165 |
+
"<div style='height: 85vh; overflow-y: auto; padding-right: 20px;'>",
|
166 |
+
unsafe_allow_html=True
|
167 |
+
)
|
168 |
+
|
169 |
st.subheader("โ ๊ถ๊ธํ ๋ด์ฉ์ ์ง๋ฌธํด๋ณด์ธ์")
|
170 |
user_question = st.text_input("์ง๋ฌธ์ ์
๋ ฅํ๊ณ ์๋ ๋ฒํผ์ ๋๋ฌ๋ณด์ธ์", key="question_input")
|
171 |
|
172 |
+
show_history = st.session_state.chat_history # ๊ธฐ๋ณธ๊ฐ
|
173 |
+
|
174 |
if st.button("๐ฌ Solar์๊ฒ ๋ฌผ์ด๋ณด๊ธฐ") and user_question:
|
175 |
with st.spinner("Solar ์ ์๋์ด ๋ต๋ณ ์ค์
๋๋ค..."):
|
176 |
answer, history, err = chat_with_solar_document(
|
|
|
186 |
st.chat_message("user").write(user_question)
|
187 |
st.chat_message("assistant").write(answer)
|
188 |
|
189 |
+
# ๊ฐ์ ์ง๋ฌธ ์ค๋ณต ๋ฐฉ์ง ์ํด ๋ง์ง๋ง ํญ๋ชฉ ์ ์ธ ์ถ๋ ฅ์ฉ ์ค๋น
|
190 |
+
show_history = st.session_state.chat_history[:-1]
|
191 |
+
|
192 |
st.session_state.keywords = get_recommended_keywords(
|
193 |
st.session_state.html_text,
|
194 |
user_question,
|
195 |
api_key
|
196 |
)
|
197 |
|
198 |
+
# ์ด์ ๋ํ ๋ด์ฉ ์ถ๋ ฅ (๋ง์ง๋ง ์ ์ธ)
|
199 |
+
for user, bot in show_history:
|
200 |
st.chat_message("user").write(user)
|
201 |
st.chat_message("assistant").write(bot)
|
202 |
|
203 |
+
# ์ถ์ฒ ํค์๋
|
204 |
if st.session_state.keywords:
|
205 |
st.markdown("### ๐ ์ถ์ฒ ๊ณต๋ถ ํค์๋")
|
206 |
st.markdown(
|
|
|
219 |
|
220 |
st.markdown("</div>", unsafe_allow_html=True)
|
221 |
|
222 |
+
# ์คํฌ๋กค ์์ญ ์ข
๋ฃ
|
223 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
224 |
+
|
225 |
# ์คํ
|
226 |
if __name__ == "__main__":
|
227 |
main()
|
228 |
+
|