Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import gradio as gr
|
|
| 4 |
|
| 5 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
| 6 |
|
|
|
|
| 7 |
generation_config = {
|
| 8 |
"temperature": 1,
|
| 9 |
"top_p": 0.95,
|
|
@@ -27,23 +28,18 @@ model = genai.GenerativeModel(
|
|
| 27 |
|
| 28 |
chat_session = model.start_chat(history=[])
|
| 29 |
|
| 30 |
-
def
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
""
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
title="학습 챗봇",
|
| 44 |
-
description="학습 목표를 입력하고 챗봇과 대화해보세요!",
|
| 45 |
-
theme="compact",
|
| 46 |
-
)
|
| 47 |
|
| 48 |
-
|
| 49 |
-
iface.launch(share=True)
|
|
|
|
| 4 |
|
| 5 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
| 6 |
|
| 7 |
+
# 모델 설정
|
| 8 |
generation_config = {
|
| 9 |
"temperature": 1,
|
| 10 |
"top_p": 0.95,
|
|
|
|
| 28 |
|
| 29 |
chat_session = model.start_chat(history=[])
|
| 30 |
|
| 31 |
+
def respond(user_input, history):
|
| 32 |
+
response = chat_session.send_message(user_input)
|
| 33 |
+
history.append((user_input, response.text))
|
| 34 |
+
return "", history
|
| 35 |
+
|
| 36 |
+
with gr.Blocks() as demo:
|
| 37 |
+
gr.Markdown("<div style='font-size: 30px; font-weight: bold;'>gemini chatbot</div>")
|
| 38 |
+
chatbot = gr.Chatbot(label="채팅창")
|
| 39 |
+
msg = gr.Textbox(label="입력")
|
| 40 |
+
clear = gr.Button("초기화")
|
| 41 |
+
|
| 42 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 43 |
+
clear.click(lambda: [], None, chatbot, queue=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
demo.launch()
|
|
|