ll7098ll commited on
Commit
feb03cf
·
verified ·
1 Parent(s): 940b028

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -35,7 +35,7 @@ model = genai.GenerativeModel(model_name="gemini-1.5-pro",
35
  generation_config=generation_config,
36
  safety_settings=safety_settings)
37
 
38
- def generate_curriculum(prompt, history=[]):
39
  prompt_parts = [
40
  "Concept-Based Curriculum Expert, If your answer is good, I'll give you a $10 tip.",
41
  "성취기준 성취 기준 및 수업 목표",
@@ -44,15 +44,21 @@ def generate_curriculum(prompt, history=[]):
44
  "개념기반 교육과정 ",
45
  ]
46
 
47
- response = model.generate_content(prompt_parts)
 
48
 
49
- # 스트리밍 출력을 위한 처리
50
- yield from response.iter_chunks()
 
 
 
 
 
51
 
52
  iface = gr.Interface(
53
  fn=generate_curriculum,
54
  inputs=gr.Textbox(lines=1, label="성취기준 입력"),
55
- outputs=gr.Chatbot(label="개념 기반 교육과정"),
56
  title="개념 기반 교육과정 챗봇",
57
  description="성취기준을 입력하면 개념 기반 교육과정을 생성합니다."
58
  )
 
35
  generation_config=generation_config,
36
  safety_settings=safety_settings)
37
 
38
+ def generate_curriculum(prompt):
39
  prompt_parts = [
40
  "Concept-Based Curriculum Expert, If your answer is good, I'll give you a $10 tip.",
41
  "성취기준 성취 기준 및 수업 목표",
 
44
  "개념기반 교육과정 ",
45
  ]
46
 
47
+ # "stream=True"를 추가하여 응답을 스트리밍 방식으로 받습니다.
48
+ response = model.generate_content(prompt_parts, stream=True)
49
 
50
+ # 전체 텍스트를 저장할 변수
51
+ full_text = ""
52
+
53
+ # 스트리밍된 텍스트를 실시간으로 출력
54
+ for chunk in response:
55
+ full_text += chunk.text
56
+ yield full_text
57
 
58
  iface = gr.Interface(
59
  fn=generate_curriculum,
60
  inputs=gr.Textbox(lines=1, label="성취기준 입력"),
61
+ outputs=gr.Textbox(lines=20, label="개념 기반 교육과정"),
62
  title="개념 기반 교육과정 챗봇",
63
  description="성취기준을 입력하면 개념 기반 교육과정을 생성합니다."
64
  )