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()