Update app.py
Browse files
app.py
CHANGED
|
@@ -23,43 +23,34 @@ model = genai.GenerativeModel(
|
|
| 23 |
generation_config=generation_config,
|
| 24 |
)
|
| 25 |
|
| 26 |
-
def
|
| 27 |
"""
|
| 28 |
-
|
| 29 |
-
아웃풋을 실시간으로 출력합니다.
|
| 30 |
Args:
|
| 31 |
-
|
|
|
|
| 32 |
Returns:
|
| 33 |
-
str: 생성된
|
| 34 |
"""
|
| 35 |
|
| 36 |
SYSTEM_PROMPT = """
|
| 37 |
-
당신은
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
- 4단계: 4단계 활동 안내...
|
| 48 |
-
4. 활동 준비물 및 기구
|
| 49 |
-
5. 활동을 위한 자료
|
| 50 |
-
- 활동에 필요한 자료
|
| 51 |
-
- 추가 추천 자료
|
| 52 |
-
6. 활동의 유의점
|
| 53 |
-
- 학생 입장 유의점
|
| 54 |
-
- 교사 입장 유의점
|
| 55 |
-
7. 학생에게 제공할 활동 안내 자료
|
| 56 |
-
* 활동 안내 자료는 초등학생이 이해할 수 있도록 최대한 구체적이고, 단계적, 명시적으로 안내해주세요.
|
| 57 |
"""
|
| 58 |
|
| 59 |
prompt = [
|
| 60 |
SYSTEM_PROMPT,
|
| 61 |
-
f"**
|
| 62 |
-
"**
|
|
|
|
| 63 |
]
|
| 64 |
|
| 65 |
response = model.generate_content(prompt, stream=True)
|
|
@@ -72,32 +63,27 @@ def generate_lesson_plan(achievement_standard):
|
|
| 72 |
|
| 73 |
# Streamlit Interface
|
| 74 |
colored_header(
|
| 75 |
-
label="
|
| 76 |
-
description="
|
| 77 |
-
color_name="
|
| 78 |
)
|
| 79 |
|
| 80 |
add_vertical_space(1)
|
| 81 |
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
-
generate_button = st.button("
|
| 85 |
|
| 86 |
# 출력 영역 정의
|
| 87 |
output_area = st.empty()
|
| 88 |
|
| 89 |
-
if generate_button and
|
| 90 |
output_text = ""
|
| 91 |
output_area.markdown(output_text)
|
| 92 |
try:
|
| 93 |
-
for partial_output in
|
| 94 |
output_text = partial_output
|
| 95 |
output_area.markdown(output_text)
|
| 96 |
except Exception as e:
|
| 97 |
-
st.error(f"오류가 발생했습니다: {str(e)}")
|
| 98 |
-
|
| 99 |
-
# 복사 버튼 추가
|
| 100 |
-
if output_text:
|
| 101 |
-
if st.button("출력 내용 복사"):
|
| 102 |
-
st.write(output_text)
|
| 103 |
-
st.success("출력 내용이 복사되었습니다!")
|
|
|
|
| 23 |
generation_config=generation_config,
|
| 24 |
)
|
| 25 |
|
| 26 |
+
def generate_pairing_recommendation(input_text, input_type):
|
| 27 |
"""
|
| 28 |
+
입력받은 안주 또는 주류에 어울리는 페어링 정보를 생성합니다.
|
|
|
|
| 29 |
Args:
|
| 30 |
+
input_text (str): 안주 또는 주류 정보
|
| 31 |
+
input_type (str): 입력 종류 ('안주' 또는 '주류')
|
| 32 |
Returns:
|
| 33 |
+
str: 생성된 페어링 정보
|
| 34 |
"""
|
| 35 |
|
| 36 |
SYSTEM_PROMPT = """
|
| 37 |
+
당신은 주류 페어링 전문가입니다.
|
| 38 |
+
사용자가 안주 또는 주류를 입력하면, 해당 안주에 어울리는 주류 또는 해당 주류에 어울리는 안주를 구체적으로 설명해주세요. 또한 각각의 특징, 맛, 향, 그리고 추천 이유를 포함하여 상세하게 작성해주세요.
|
| 39 |
+
한국인의 취향에 맞는 주류나 안주를 추천해주세요. 추천 점수를 10점 만점으로 표현해주세요.
|
| 40 |
+
다음은 페어링 추천에 필요한 정보입니다.
|
| 41 |
+
**페어링 구성 요소:**
|
| 42 |
+
1. 추천 주류/안주 소개
|
| 43 |
+
2. 맛과 향 설명
|
| 44 |
+
3. 추천 이유
|
| 45 |
+
4. 추가 추천 페어링
|
| 46 |
+
5. 추천 점수 (10점 만점)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
"""
|
| 48 |
|
| 49 |
prompt = [
|
| 50 |
SYSTEM_PROMPT,
|
| 51 |
+
f"**입력 종류:** {input_type}",
|
| 52 |
+
f"**입력 내용:** {input_text}",
|
| 53 |
+
"**추천 페어링:**",
|
| 54 |
]
|
| 55 |
|
| 56 |
response = model.generate_content(prompt, stream=True)
|
|
|
|
| 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 |
+
input_text = st.text_area("안주 또는 주류 입력", height=100)
|
| 74 |
+
input_type = st.radio("입력 종류 선택", ("안주", "주류"))
|
| 75 |
|
| 76 |
+
generate_button = st.button("페어링 추천 생성")
|
| 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 |
+
for partial_output in generate_pairing_recommendation(input_text, input_type):
|
| 86 |
output_text = partial_output
|
| 87 |
output_area.markdown(output_text)
|
| 88 |
except Exception as e:
|
| 89 |
+
st.error(f"오류가 발생했습니다: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|