Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,14 +5,15 @@ import google.generativeai as genai
|
|
| 5 |
from streamlit_extras.colored_header import colored_header
|
| 6 |
from streamlit_extras.add_vertical_space import add_vertical_space
|
| 7 |
import markdown
|
|
|
|
| 8 |
|
| 9 |
# Google Gemini API Key 설정
|
| 10 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
| 11 |
|
| 12 |
# 모델 설정
|
| 13 |
generation_config = {
|
| 14 |
-
"temperature":
|
| 15 |
-
"top_p": 0.
|
| 16 |
"top_k": 40,
|
| 17 |
"max_output_tokens": 8192,
|
| 18 |
"response_mime_type": "text/plain",
|
|
@@ -62,28 +63,55 @@ def generate_pairing_recommendation(input_text, input_type):
|
|
| 62 |
time.sleep(0.03) # 출력 속도 조절
|
| 63 |
|
| 64 |
# Streamlit Interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
colored_header(
|
| 66 |
-
label="주류 페어링 도우미",
|
| 67 |
-
description="안주 또는 주류를 입력하시면 어울리는 페어링 정보를 추천해드립니다.",
|
| 68 |
color_name="blue-70",
|
| 69 |
)
|
| 70 |
|
| 71 |
add_vertical_space(1)
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
# 출력 영역 정의
|
| 79 |
output_area = st.empty()
|
| 80 |
|
|
|
|
| 81 |
if generate_button and input_text:
|
| 82 |
output_text = ""
|
| 83 |
output_area.markdown(output_text)
|
| 84 |
try:
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
| 88 |
except Exception as e:
|
| 89 |
-
st.error(f"오류가 발생했습니다: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from streamlit_extras.colored_header import colored_header
|
| 6 |
from streamlit_extras.add_vertical_space import add_vertical_space
|
| 7 |
import markdown
|
| 8 |
+
from streamlit_extras.stoggle import stoggle # 추가된 라이브러리
|
| 9 |
|
| 10 |
# Google Gemini API Key 설정
|
| 11 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
| 12 |
|
| 13 |
# 모델 설정
|
| 14 |
generation_config = {
|
| 15 |
+
"temperature": 0.5,
|
| 16 |
+
"top_p": 0.7,
|
| 17 |
"top_k": 40,
|
| 18 |
"max_output_tokens": 8192,
|
| 19 |
"response_mime_type": "text/plain",
|
|
|
|
| 63 |
time.sleep(0.03) # 출력 속도 조절
|
| 64 |
|
| 65 |
# Streamlit Interface
|
| 66 |
+
st.set_page_config(
|
| 67 |
+
page_title="주류 페어링 도우미",
|
| 68 |
+
page_icon="🍷",
|
| 69 |
+
layout="centered",
|
| 70 |
+
initial_sidebar_state="expanded",
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
colored_header(
|
| 74 |
+
label="🍷 주류 페어링 도우미",
|
| 75 |
+
description="안주 또는 주류를 입력하시면 어울리는 페어링 정보를 추천해드립니다. 한국인의 입맛에 딱 맞는 페어링 정보를 찾아보세요!",
|
| 76 |
color_name="blue-70",
|
| 77 |
)
|
| 78 |
|
| 79 |
add_vertical_space(1)
|
| 80 |
|
| 81 |
+
# 사용자 입력 영역
|
| 82 |
+
tabs = st.tabs(["🍝 안주 입력", "🍇 주류 입력"])
|
| 83 |
+
|
| 84 |
+
with tabs[0]:
|
| 85 |
+
st.markdown("#### 안주를 입력해 주세요:")
|
| 86 |
+
input_text_anjoo = st.text_area("예: 치킨, 육회, 치즈 플래터 등", height=100)
|
| 87 |
+
|
| 88 |
+
with tabs[1]:
|
| 89 |
+
st.markdown("#### 주류를 입력해 주세요:")
|
| 90 |
+
input_text_liquor = st.text_area("예: 맥주, 와인, 소주 등", height=100)
|
| 91 |
|
| 92 |
+
input_type = "안주" if input_text_anjoo else "주류"
|
| 93 |
+
input_text = input_text_anjoo if input_text_anjoo else input_text_liquor
|
| 94 |
+
|
| 95 |
+
generate_button = st.button("🍻 페어링 추천 받기")
|
| 96 |
|
| 97 |
# 출력 영역 정의
|
| 98 |
output_area = st.empty()
|
| 99 |
|
| 100 |
+
# 추천 결과 생성 및 출력
|
| 101 |
if generate_button and input_text:
|
| 102 |
output_text = ""
|
| 103 |
output_area.markdown(output_text)
|
| 104 |
try:
|
| 105 |
+
with st.spinner("페어링 정보를 생성 중입니다... 잠시만 기다려 주세요!"):
|
| 106 |
+
for partial_output in generate_pairing_recommendation(input_text, input_type):
|
| 107 |
+
output_text = partial_output
|
| 108 |
+
output_area.markdown(output_text)
|
| 109 |
except Exception as e:
|
| 110 |
+
st.error(f"오류가 발생했습니다: {str(e)}")
|
| 111 |
+
|
| 112 |
+
# 추가 정보 및 FAQ
|
| 113 |
+
add_vertical_space(2)
|
| 114 |
+
stoggle(
|
| 115 |
+
"📜 주류 페어링 FAQ",
|
| 116 |
+
"이 앱은 안주와 주류에 대한 전문적인 페어링 정보를 제공합니다. 한국인의 입맛에 맞춘 추천을 통해 최고의 안주와 주류 조합을 즐기세요!\n\n\n**Q: 모든 안주와 주류를 추천받을 수 있나요?**\n\nA: 예, 다양한 안주와 주류에 대해 추천받을 수 있으며, 지속적으로 업데이트됩니다.",
|
| 117 |
+
)
|