ll7098ll commited on
Commit
401ecd3
·
verified ·
1 Parent(s): 8ab7272

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import os
2
  import google.generativeai as genai
 
3
  import gradio as gr
4
 
5
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
6
 
7
- # Set up the model
8
  generation_config = {
9
  "temperature": 1,
10
  "top_p": 0.95,
@@ -47,12 +47,21 @@ def generate_curriculum(prompt):
47
  response = model.generate_content(prompt_parts)
48
  return response.text
49
 
50
- iface = gr.Interface(
51
- fn=generate_curriculum,
52
- inputs=gr.Textbox(lines=1, label="성취기준 입력"),
53
- outputs=gr.Textbox(lines=20, label="개념 기반 교육과정"),
 
 
 
 
 
 
 
 
 
54
  title="개념 기반 교육과정 챗봇",
55
  description="성취기준을 입력하면 개념 기반 교육과정을 생성합니다."
56
  )
57
 
58
- iface.launch()
 
1
  import os
2
  import google.generativeai as genai
3
+ import time
4
  import gradio as gr
5
 
6
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
7
 
 
8
  generation_config = {
9
  "temperature": 1,
10
  "top_p": 0.95,
 
47
  response = model.generate_content(prompt_parts)
48
  return response.text
49
 
50
+ def chat_bot(message, history):
51
+ history.append((message, ""))
52
+ if message:
53
+ response = generate_curriculum(message)
54
+ for char in response:
55
+ history[-1] = (message, history[-1][1] + char)
56
+ yield history
57
+ time.sleep(0.05) # Adjust the delay as needed
58
+ history[-1] = (message, response)
59
+ yield history
60
+
61
+ iface = gr.ChatInterface(
62
+ fn=chat_bot,
63
  title="개념 기반 교육과정 챗봇",
64
  description="성취기준을 입력하면 개념 기반 교육과정을 생성합니다."
65
  )
66
 
67
+ iface.launch()