ll7098ll commited on
Commit
56cd9ca
Β·
verified Β·
1 Parent(s): c52b1d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -20
app.py CHANGED
@@ -1,18 +1,20 @@
1
  import os
2
  import time
3
-
4
  import google.generativeai as genai
5
- import gradio as gr
 
 
6
 
7
- # Google Gemini API ν‚€ μ„€μ •
8
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
9
 
10
  # λͺ¨λΈ μ„€μ •
11
  generation_config = {
12
- "temperature": 1.5,
13
- "top_p": 0.8,
14
  "top_k": 40,
15
- "max_output_tokens": 15000,
16
  "response_mime_type": "text/plain",
17
  }
18
 
@@ -49,7 +51,6 @@ SYSTEM_PROMPT = """
49
  - 학생 μž…μž₯ 유의점
50
  - ꡐ사 μž…μž₯ 유의점
51
  7. ν•™μƒμ—κ²Œ μ œκ³΅ν•  ν™œλ™ μ•ˆλ‚΄ 자료
52
-
53
  * ν™œλ™ μ•ˆλ‚΄ μžλ£ŒλŠ” μ΄ˆλ“±ν•™μƒμ΄ 이해할 수 μžˆλ„λ‘ μ΅œλŒ€ν•œ ꡬ체적이고, 단계적, λͺ…μ‹œμ μœΌλ‘œ μ•ˆλ‚΄ν•΄μ£Όμ„Έμš”.
54
  """
55
 
@@ -77,19 +78,34 @@ def generate_curriculum(topic):
77
  yield collected_text # μ‹€μ‹œκ°„ 좜λ ₯을 μœ„ν•΄ yield μ‚¬μš©
78
  time.sleep(0.03) # 좜λ ₯ 속도 쑰절
79
 
80
- # Gradio μΈν„°νŽ˜μ΄μŠ€ μ„€μ •
81
- iface = gr.Interface(
82
- fn=generate_curriculum,
83
- inputs=gr.Textbox(lines=1, label="ν™œλ™ 주제 μž…λ ₯"),
84
- outputs=gr.Textbox(lines=10, label="κ²Œμ΄λ―Έν”ΌμΌ€μ΄μ…˜ μˆ˜μ—… 섀계"),
85
- title="κ²Œμ΄λ―Έν”ΌμΌ€μ΄μ…˜ μˆ˜μ—… 섀계 λ„μš°λ―Έ",
86
  description="μ„ μƒλ‹˜μ΄ ν™œλ™ 주제λ₯Ό μž…λ ₯ν•˜μ‹œλ©΄ κ²Œμ΄λ―Έν”ΌμΌ€μ΄μ…˜ μš”μ†Œλ₯Ό ν¬ν•¨ν•˜μ—¬ μˆ˜μ—…μ„ ꡬ체적으둜 μ„€κ³„ν•΄μ€λ‹ˆλ‹€.",
87
- examples=[
88
- ["μž„μ§„μ™œλž€"],
89
- ["μ—λ„ˆμ§€ μ „ν™˜"],
90
- ["ν•œ 자리수 λ§μ…ˆκ³Ό λΊ„μ…ˆ"],
91
- ]
92
  )
93
 
94
- # μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰
95
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import time
3
+ import streamlit as st
4
  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": 1,
15
+ "top_p": 0.95,
16
  "top_k": 40,
17
+ "max_output_tokens": 8192,
18
  "response_mime_type": "text/plain",
19
  }
20
 
 
51
  - 학생 μž…μž₯ 유의점
52
  - ꡐ사 μž…μž₯ 유의점
53
  7. ν•™μƒμ—κ²Œ μ œκ³΅ν•  ν™œλ™ μ•ˆλ‚΄ 자료
 
54
  * ν™œλ™ μ•ˆλ‚΄ μžλ£ŒλŠ” μ΄ˆλ“±ν•™μƒμ΄ 이해할 수 μžˆλ„λ‘ μ΅œλŒ€ν•œ ꡬ체적이고, 단계적, λͺ…μ‹œμ μœΌλ‘œ μ•ˆλ‚΄ν•΄μ£Όμ„Έμš”.
55
  """
56
 
 
78
  yield collected_text # μ‹€μ‹œκ°„ 좜λ ₯을 μœ„ν•΄ yield μ‚¬μš©
79
  time.sleep(0.03) # 좜λ ₯ 속도 쑰절
80
 
81
+ # Streamlit Interface
82
+ colored_header(
83
+ label="κ²Œμ΄λ―Έν”ΌμΌ€μ΄μ…˜ μˆ˜μ—… 섀계 λ„μš°λ―Έ",
 
 
 
84
  description="μ„ μƒλ‹˜μ΄ ν™œλ™ 주제λ₯Ό μž…λ ₯ν•˜μ‹œλ©΄ κ²Œμ΄λ―Έν”ΌμΌ€μ΄μ…˜ μš”μ†Œλ₯Ό ν¬ν•¨ν•˜μ—¬ μˆ˜μ—…μ„ ꡬ체적으둜 μ„€κ³„ν•΄μ€λ‹ˆλ‹€.",
85
+ color_name="red-70",
 
 
 
 
86
  )
87
 
88
+ add_vertical_space(1)
89
+
90
+ achievement_standard = st.text_area("ν™œλ™ 컨셉 및 μ†Œκ°œ μž…λ ₯", height=100)
91
+
92
+ generate_button = st.button("κ²Œμ΄λ―Έν”ΌμΌ€μ΄μ…˜ μˆ˜μ—… 섀계")
93
+
94
+ # 좜λ ₯ μ˜μ—­ μ •μ˜
95
+ output_area = st.empty()
96
+
97
+ if generate_button and achievement_standard:
98
+ output_text = ""
99
+ output_area.markdown(output_text)
100
+ try:
101
+ for partial_output in generate_lesson_plan(achievement_standard):
102
+ output_text = partial_output
103
+ output_area.markdown(output_text)
104
+ except Exception as e:
105
+ st.error(f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}")
106
+
107
+ # 볡사 λ²„νŠΌ μΆ”κ°€
108
+ if output_text:
109
+ if st.button("좜λ ₯ λ‚΄μš© 볡사"):
110
+ st.write(output_text)
111
+ st.success("좜λ ₯ λ‚΄μš©μ΄ λ³΅μ‚¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€!")