File size: 2,167 Bytes
1d355ad
22032f3
 
1d355ad
22032f3
 
940b028
22032f3
39688bd
 
 
 
22032f3
39688bd
22032f3
39688bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22032f3
 
39688bd
 
 
f74a421
feb03cf
8ab7272
 
 
 
 
 
 
217a78d
feb03cf
 
940b028
feb03cf
 
 
 
 
 
 
940b028
 
 
 
feb03cf
8ab7272
 
39688bd
03d0703
401ecd3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import google.generativeai as genai
import gradio as gr

genai.configure(api_key=os.environ["GEMINI_API_KEY"])

# Set up the model
generation_config = {
  "temperature": 1,
  "top_p": 0.95,
  "top_k": 64,
  "max_output_tokens": 8192,
}

safety_settings = [
  {
    "category": "HARM_CATEGORY_HARASSMENT",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
  {
    "category": "HARM_CATEGORY_HATE_SPEECH",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
  {
    "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
  {
    "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
    "threshold": "BLOCK_MEDIUM_AND_ABOVE"
  },
]

model = genai.GenerativeModel(model_name="gemini-1.5-pro",
                              generation_config=generation_config,
                              safety_settings=safety_settings)

def generate_curriculum(prompt):
  prompt_parts = [
    "Concept-Based Curriculum Expert, If your answer is good, I'll give you a $10 tip.",
    "성취기준 성취 기준 및 수업 목표",
    "개념기반 교육과정 1. 핵심 아이디어(일반화된 지식)\n\n2. 매크로 개념(개념적 렌즈), 마이크로 개념(교과 개념)\n\n3. 사실적 지식, 주제, 개념, 원리 및 일반화, 이론\n\n4. 스트랜드와 차시별 학습활동\n\n5. 평가 내용 및 방법, 평가 루브릭(상, 중, 하 평어 예시 포함)\n\n6. 개념적 이해를 위한 팁",
    prompt,
    "개념기반 교육과정 ",
  ]

  # "stream=True"를 추가하여 응답을 스트리밍 방식으로 받습니다.
  response = model.generate_content(prompt_parts, stream=True)
  
  # 전체 텍스트를 저장할 변수
  full_text = ""

  # 스트리밍된 텍스트를 실시간으로 출력
  for chunk in response:
    full_text += chunk.text
    yield full_text

iface = gr.Interface(
    fn=generate_curriculum,
    inputs=gr.Textbox(lines=1, label="성취기준 입력"),
    outputs=gr.Textbox(lines=20, label="개념 기반 교육과정"),
    title="개념 기반 교육과정 챗봇",
    description="성취기준을 입력하면 개념 기반 교육과정을 생성합니다."
)

iface.launch()