Update app.py
Browse files
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 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|