Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -156,12 +156,18 @@ st.markdown("""
|
|
| 156 |
font-size: 1.5em;
|
| 157 |
font-weight: bold;
|
| 158 |
color: #333;
|
|
|
|
|
|
|
|
|
|
| 159 |
}
|
| 160 |
@keyframes scrolling {
|
| 161 |
-
0% {transform: translateX(
|
| 162 |
-
|
|
|
|
|
|
|
| 163 |
}
|
| 164 |
|
|
|
|
| 165 |
/* ๋ชจ๋ฐ์ผ ๋์์ ์ํ CSS ์ถ๊ฐ */
|
| 166 |
@media (max-width: 600px) {
|
| 167 |
.time-container {
|
|
@@ -711,48 +717,13 @@ def show_temperature_graph(data):
|
|
| 711 |
|
| 712 |
# ๋ ์จ ์๋ณด ์์ฑ ๋ฐ ํ์ ๋ถ๋ถ์ ์ธ์
์ํ๋ก ๊ด๋ฆฌ
|
| 713 |
if 'weather_forecast' not in st.session_state:
|
| 714 |
-
client = OpenAI(
|
| 715 |
-
api_key="glhf_9ea0e0babe1e45353dd03b44cb979e22",
|
| 716 |
-
base_url="https://glhf.chat/api/openai/v1",
|
| 717 |
-
http_client=httpx.Client(
|
| 718 |
-
follow_redirects=True,
|
| 719 |
-
timeout=30.0
|
| 720 |
-
)
|
| 721 |
-
)
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
# ํ์ฌ ์๊ฐ๊ณผ ์๋ณด ์๊ฐ ์ ๋ณด ์ถ๊ฐ
|
| 725 |
-
current_time = datetime.utcnow() + timedelta(hours=9)
|
| 726 |
-
current_date_str = current_time.strftime('%Y๋
%m์ %d์ผ')
|
| 727 |
-
tomorrow_date_str = (current_time + timedelta(days=1)).strftime('%Y๋
%m์ %d์ผ')
|
| 728 |
-
|
| 729 |
forecast_data_str = "\n".join([
|
| 730 |
f"[{f['FCST_DT'][:4]}๋
{f['FCST_DT'][4:6]}์ {f['FCST_DT'][6:8]}์ผ {f['FCST_DT'][8:10]}์] {temp}๋, {description}"
|
| 731 |
for f, time, temp, description in zip(valid_forecast_data, times, temps, weather_descriptions)
|
| 732 |
])
|
| 733 |
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
messages=[
|
| 737 |
-
{"role": "system", "content": "๋น์ ์ ๋ ์จ ์๋ณด๊ด์
๋๋ค. ์ฃผ์ด์ง ์๊ฐ๋๋ณ ๋ ์จ ๋ฐ์ดํฐ๋ฅผ ๋ฐํ์ผ๋ก ์ ํํ ๋ ์จ ์๋ณด๋ฅผ ์์ฑํด์ฃผ์ธ์."},
|
| 738 |
-
{"role": "user", "content": f"""ํ์ฌ ์๊ฐ์ {current_time.strftime('%H์ %M๋ถ')}์
๋๋ค.
|
| 739 |
-
|
| 740 |
-
๋ค์ FCST_DT์ ์๊ฐ๋๋ณ ๋ ์จ ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ณ ์ค์ ๋ ์จ ์ํฉ์ ๋ง๋ ์ ํํ ๋ ์จ ์๋ณด๋ฅผ 200์์ ์์ฐ์ค๋ฌ์ด ๋ฌธ์ฅ์ผ๋ก ๋ง๋ค์ด์ฃผ์ธ์. ๋น๋ ๋ ์๋ณด๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง ์ฐ์ฐ์ ์ค๋นํ๋๋ก ์๋ดํด์ฃผ์ธ์. ์ท์ฐจ๋ฆผ์ ๋ค์์ ์ฐธ๊ณ ํ์ธ์.
|
| 741 |
-
27ยฐC์ด์: ๋ฐํํฐ, ๋ฐ๋ฐ์ง, ๋ฏผ์๋งค
|
| 742 |
-
23ยฐC~26ยฐC: ์์ ์
์ธ , ๋ฐํํฐ, ๋ฐ๋ฐ์ง, ๋ฉด๋ฐ์ง
|
| 743 |
-
20ยฐC~22ยฐC: ์์ ๊ฐ๋๊ฑด, ๊ธดํํฐ, ๊ธด๋ฐ์ง
|
| 744 |
-
17ยฐC~19ยฐC: ์์ ๋ํธ, ๊ฐ๋๊ฑด, ๋งจํฌ๋งจ, ์์ ์์ผ, ๊ธด๋ฐ์ง
|
| 745 |
-
12ยฐC~16ยฐC: ์์ผ, ๊ฐ๋๊ฑด, ์ผ์, ๋งจํฌ๋งจ, ๋ํธ, ์คํํน, ๊ธด๋ฐ์ง
|
| 746 |
-
9ยฐC~11ยฐC: ํธ๋ ์น์ฝํธ, ์ผ์, ๊ฐ์ฃฝ ์์ผ, ์คํํน, ๊ธด๋ฐ์ง
|
| 747 |
-
5ยฐC~8ยฐC: ์ฝํธ, ํํธํ
, ๋ํธ, ๊ธด๋ฐ์ง
|
| 748 |
-
4ยฐC์ดํ: ํจ๋ฉ, ๋๊บผ์ด ์ฝํธ, ๋ชฉ๋๋ฆฌ, ๊ธฐ๋ชจ์ ํ
|
| 749 |
-
|
| 750 |
-
์๊ฐ๋๋ณ ๋ ์จ ๋ฐ์ดํฐ:
|
| 751 |
-
{forecast_data_str}"""}
|
| 752 |
-
]
|
| 753 |
-
)
|
| 754 |
-
|
| 755 |
-
st.session_state.weather_forecast = response.choices[0].message.content
|
| 756 |
|
| 757 |
# ์ ์ฅ๋ ๋ ์จ ์๋ณด ํ์
|
| 758 |
st.markdown(f'''
|
|
@@ -771,6 +742,40 @@ def show_temperature_graph(data):
|
|
| 771 |
|
| 772 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 773 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 774 |
def main():
|
| 775 |
if 'current_section' not in st.session_state:
|
| 776 |
st.session_state.current_section = 'weather'
|
|
|
|
| 156 |
font-size: 1.5em;
|
| 157 |
font-weight: bold;
|
| 158 |
color: #333;
|
| 159 |
+
position: relative;
|
| 160 |
+
left: 50%;
|
| 161 |
+
transform: translateX(-50%);
|
| 162 |
}
|
| 163 |
@keyframes scrolling {
|
| 164 |
+
0% {transform: translateX(0%); opacity: 0;}
|
| 165 |
+
10% {opacity: 1;}
|
| 166 |
+
90% {opacity: 1;}
|
| 167 |
+
100% {transform: translateX(-100%); opacity: 0;}
|
| 168 |
}
|
| 169 |
|
| 170 |
+
|
| 171 |
/* ๋ชจ๋ฐ์ผ ๋์์ ์ํ CSS ์ถ๊ฐ */
|
| 172 |
@media (max-width: 600px) {
|
| 173 |
.time-container {
|
|
|
|
| 717 |
|
| 718 |
# ๋ ์จ ์๋ณด ์์ฑ ๋ฐ ํ์ ๋ถ๋ถ์ ์ธ์
์ํ๋ก ๊ด๋ฆฌ
|
| 719 |
if 'weather_forecast' not in st.session_state:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 720 |
forecast_data_str = "\n".join([
|
| 721 |
f"[{f['FCST_DT'][:4]}๋
{f['FCST_DT'][4:6]}์ {f['FCST_DT'][6:8]}์ผ {f['FCST_DT'][8:10]}์] {temp}๋, {description}"
|
| 722 |
for f, time, temp, description in zip(valid_forecast_data, times, temps, weather_descriptions)
|
| 723 |
])
|
| 724 |
|
| 725 |
+
current_time_str = current_time.strftime('%H์ %M๋ถ')
|
| 726 |
+
st.session_state.weather_forecast = get_weather_forecast(forecast_data_str, current_time_str)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 727 |
|
| 728 |
# ์ ์ฅ๋ ๋ ์จ ์๋ณด ํ์
|
| 729 |
st.markdown(f'''
|
|
|
|
| 742 |
|
| 743 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 744 |
|
| 745 |
+
@st.cache_data(ttl=300) # 5๋ถ ์บ์
|
| 746 |
+
def get_weather_forecast(forecast_data_str, current_time_str):
|
| 747 |
+
client = OpenAI(
|
| 748 |
+
api_key="glhf_9ea0e0babe1e45353dd03b44cb979e22",
|
| 749 |
+
base_url="https://glhf.chat/api/openai/v1",
|
| 750 |
+
http_client=httpx.Client(
|
| 751 |
+
follow_redirects=True,
|
| 752 |
+
timeout=30.0
|
| 753 |
+
)
|
| 754 |
+
)
|
| 755 |
+
|
| 756 |
+
response = client.chat.completions.create(
|
| 757 |
+
model="hf:Nexusflow/Athene-V2-Chat",
|
| 758 |
+
messages=[
|
| 759 |
+
{"role": "system", "content": "๋น์ ์ ๋ ์จ ์๋ณด๊ด์
๋๋ค. ์ฃผ์ด์ง ์๊ฐ๋๋ณ ๋ ์จ ๋ฐ์ดํฐ๋ฅผ ๋ฐํ์ผ๋ก ์ ํํ ๋ ์จ ์๋ณด๋ฅผ ์์ฑํด์ฃผ์ธ์."},
|
| 760 |
+
{"role": "user", "content": f"""ํ์ฌ ์๊ฐ์ {current_time_str}์
๋๋ค.
|
| 761 |
+
|
| 762 |
+
๋ค์ FCST_DT์ ์๊ฐ๋๋ณ ๋ ์จ ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ณ ์ค์ ๋ ์จ ์ํฉ์ ๋ง๋ ์ ํํ ๋ ์จ ์๋ณด๋ฅผ 200์์ ์์ฐ์ค๋ฌ์ด ๋ฌธ์ฅ์ผ๋ก ๋ง๋ค์ด์ฃผ์ธ์. ๋น๋ ๋ ์๋ณด๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง ์ฐ์ฐ์ ์ค๋นํ๋๋ก ์๋ดํด์ฃผ์ธ์. ์ท์ฐจ๋ฆผ์ ๋ค์์ ์ฐธ๊ณ ํ์ธ์.
|
| 763 |
+
27ยฐC์ด์: ๋ฐํํฐ, ๋ฐ๋ฐ์ง, ๋ฏผ์๋งค
|
| 764 |
+
23ยฐC~26ยฐC: ์์ ์
์ธ , ๋ฐํํฐ, ๋ฐ๋ฐ์ง, ๋ฉด๋ฐ์ง
|
| 765 |
+
20ยฐC~22ยฐC: ์์ ๊ฐ๋๊ฑด, ๊ธดํํฐ, ๊ธด๋ฐ์ง
|
| 766 |
+
17ยฐC~19ยฐC: ์์ ๋ํธ, ๊ฐ๋๊ฑด, ๋งจํฌ๋งจ, ์์ ์์ผ, ๊ธด๋ฐ์ง
|
| 767 |
+
12ยฐC~16ยฐC: ์์ผ, ๊ฐ๋๊ฑด, ์ผ์, ๋งจํฌ๋งจ, ๋ํธ, ์คํํน, ๊ธด๋ฐ์ง
|
| 768 |
+
9ยฐC~11ยฐC: ํธ๋ ์น์ฝํธ, ์ผ์, ๊ฐ์ฃฝ ์์ผ, ์คํํน, ๊ธด๋ฐ์ง
|
| 769 |
+
5ยฐC~8ยฐC: ์ฝํธ, ํํธํ
, ๋ํธ, ๊ธด๋ฐ์ง
|
| 770 |
+
4ยฐC์ดํ: ํจ๋ฉ, ๋๊บผ์ด ์ฝํธ, ๋ชฉ๋๋ฆฌ, ๊ธฐ๋ชจ์ ํ
|
| 771 |
+
|
| 772 |
+
์๊ฐ๋๋ณ ๋ ์จ ๋ฐ์ดํฐ:
|
| 773 |
+
{forecast_data_str}"""}
|
| 774 |
+
]
|
| 775 |
+
)
|
| 776 |
+
return response.choices[0].message.content
|
| 777 |
+
|
| 778 |
+
|
| 779 |
def main():
|
| 780 |
if 'current_section' not in st.session_state:
|
| 781 |
st.session_state.current_section = 'weather'
|