ll7098ll commited on
Commit
b05b815
ยท
verified ยท
1 Parent(s): a7457de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -32
app.py CHANGED
@@ -5,38 +5,39 @@ import time
5
 
6
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
7
 
8
- # Set up the model
9
- generation_config = {
10
- "temperature": 1,
11
- "top_p": 0.95,
12
- "top_k": 64,
13
- "max_output_tokens": 8192,
14
- }
 
15
 
16
- safety_settings = [
17
- {
18
- "category": "HARM_CATEGORY_HARASSMENT",
19
- "threshold": "BLOCK_NONE"
20
- },
21
- {
22
- "category": "HARM_CATEGORY_HATE_SPEECH",
23
- "threshold": "BLOCK_NONE"
24
- },
25
- {
26
- "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
27
- "threshold": "BLOCK_NONE"
28
- },
29
- {
30
- "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
31
- "threshold": "BLOCK_NONE"
32
- },
33
- ]
34
 
35
- model = genai.GenerativeModel(model_name="gemini-1.5-pro",
 
36
  generation_config=generation_config,
37
  safety_settings=safety_settings)
38
 
39
- def generate_curriculum(prompt):
40
  prompt_parts = [
41
  "Concept-based inquiry learning expert",
42
  "ํ•™์Šต์ฃผ์ œ ํ•™์Šต์ฃผ์ œ",
@@ -55,14 +56,15 @@ def generate_curriculum(prompt):
55
  yield full_text
56
  time.sleep(0.05) # ์•ฝ๊ฐ„์˜ ์ง€์—ฐ ์ถ”๊ฐ€
57
  except Exception as e:
58
- yield f"์—๋Ÿฌ ๋ฐœ์ƒ: {str(e)}"
59
 
 
60
  iface = gr.Interface(
61
  fn=generate_curriculum,
62
- inputs=gr.Textbox(lines=1, label="ํ•™์Šต์ฃผ์ œ ์ž…๋ ฅ"),
63
- outputs=gr.Textbox(lines=20, label="๊ฐœ๋…๊ธฐ๋ฐ˜ ํƒ๊ตฌํ•™์Šต"),
64
- title="๊ฐœ๋…๊ธฐ๋ฐ˜ ํƒ๊ตฌํ•™์Šต ์ฑ—๋ด‡",
65
- description="ํ•™์Šต์ฃผ์ œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ฐœ๋…๊ธฐ๋ฐ˜ ํƒ๊ตฌํ•™์Šต์„ ์„ค๊ณ„ํ•ฉ๋‹ˆ๋‹ค."
66
  )
67
 
68
  iface.launch()
 
5
 
6
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
7
 
8
+ # ๋ชจ๋ธ ์„ค์ •์„ ํ•จ์ˆ˜ ๋‚ด๋ถ€๋กœ ์ด๋™
9
+ def generate_curriculum(prompt):
10
+ generation_config = {
11
+ "temperature": 1,
12
+ "top_p": 0.95,
13
+ "top_k": 64,
14
+ "max_output_tokens": 15000,
15
+ }
16
 
17
+ safety_settings = [
18
+ {
19
+ "category": "HARM_CATEGORY_HARASSMENT",
20
+ "threshold": "BLOCK_NONE"
21
+ },
22
+ {
23
+ "category": "HARM_CATEGORY_HATE_SPEECH",
24
+ "threshold": "BLOCK_NONE"
25
+ },
26
+ {
27
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
28
+ "threshold": "BLOCK_NONE"
29
+ },
30
+ {
31
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
32
+ "threshold": "BLOCK_NONE"
33
+ },
34
+ ]
35
 
36
+ # ์„ธ์…˜๋งˆ๋‹ค ์ƒˆ๋กœ์šด ๋ชจ๋ธ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
37
+ model = genai.GenerativeModel(model_name="gemini-1.5-pro",
38
  generation_config=generation_config,
39
  safety_settings=safety_settings)
40
 
 
41
  prompt_parts = [
42
  "Concept-based inquiry learning expert",
43
  "ํ•™์Šต์ฃผ์ œ ํ•™์Šต์ฃผ์ œ",
 
56
  yield full_text
57
  time.sleep(0.05) # ์•ฝ๊ฐ„์˜ ์ง€์—ฐ ์ถ”๊ฐ€
58
  except Exception as e:
59
+ yield f"์—๋Ÿฌ ๋ฐœ์ƒ: {str(e)}"
60
 
61
+ # ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • (๋ณ€๊ฒฝ ์—†์Œ)
62
  iface = gr.Interface(
63
  fn=generate_curriculum,
64
+ inputs=gr.Textbox(lines=1, label="์„ฑ์ทจ๊ธฐ์ค€ ์ž…๋ ฅ"),
65
+ outputs=gr.Textbox(lines=20, label="๊ฐœ๋…๊ธฐ๋ฐ˜ ๊ต์œก๊ณผ์ •"),
66
+ title="๊ฐœ๋…๊ธฐ๋ฐ˜ ๊ต์œก๊ณผ์ • ์ฑ—๋ด‡",
67
+ description="์„ฑ์ทจ๊ธฐ์ค€์„ ์ž…๋ ฅํ•˜๋ฉด ๊ฐœ๋…๊ธฐ๋ฐ˜ ๊ต์œก๊ณผ์ •์„ ์„ค๊ณ„ํ•ฉ๋‹ˆ๋‹ค."
68
  )
69
 
70
  iface.launch()