Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
class
|
| 6 |
def __init__(self):
|
| 7 |
# ํ๊น
ํ์ด์ค ์คํ์ด์ค์์๋ secrets์์ API ํค ๊ฐ์ ธ์ค๊ธฐ
|
| 8 |
api_key = os.getenv("GEMINI_API_KEY")
|
|
@@ -13,9 +13,9 @@ class SimpleBanchanChatbot:
|
|
| 13 |
genai.configure(api_key=api_key)
|
| 14 |
self.model = genai.GenerativeModel('gemini-2.0-flash-exp')
|
| 15 |
|
| 16 |
-
#
|
| 17 |
self.faq_data = """
|
| 18 |
-
๋ฐ์ฐฌ๊ฐ๊ฒ ๊ณ ๊ฐ์ผํฐ FAQ:
|
| 19 |
|
| 20 |
== ๊ธฐ๋ณธ ์ ๋ณด ==
|
| 21 |
โข ๊ณ ๊ฐ์ผํฐ: 010-8082-0047
|
|
@@ -103,7 +103,7 @@ class SimpleBanchanChatbot:
|
|
| 103 |
|
| 104 |
def chat_stream(self, message, history):
|
| 105 |
system_prompt = f"""
|
| 106 |
-
๋น์ ์
|
| 107 |
|
| 108 |
{self.faq_data}
|
| 109 |
|
|
@@ -112,7 +112,7 @@ class SimpleBanchanChatbot:
|
|
| 112 |
- FAQ์ ์๋ ๋ด์ฉ์ "์์ธํ ์ฌํญ์ ๊ณ ๊ฐ์ผํฐ(010-8082-0047)๋ก ๋ฌธ์ํด์ฃผ์ธ์"๋ผ๊ณ ์๋ดํด์ฃผ์ธ์
|
| 113 |
- ๋ฐ๋ง๋ณด๋ค๋ ์กด๋๋ง์ ์ฌ์ฉํด์ฃผ์ธ์
|
| 114 |
- ๊ฐ๊ฒฐํ๊ณ ์ดํดํ๊ธฐ ์ฝ๊ฒ ๋ต๋ณํด์ฃผ์ธ์
|
| 115 |
-
-
|
| 116 |
"""
|
| 117 |
|
| 118 |
print(f"์ฌ์ฉ์ ์ง๋ฌธ: {message}")
|
|
@@ -138,13 +138,13 @@ class SimpleBanchanChatbot:
|
|
| 138 |
|
| 139 |
# ์ฑ๋ด ์ธ์คํด์ค ์์ฑ
|
| 140 |
try:
|
| 141 |
-
chatbot =
|
| 142 |
|
| 143 |
# ๊ทธ๋ผ๋์ค ์ธํฐํ์ด์ค
|
| 144 |
demo = gr.ChatInterface(
|
| 145 |
fn=chatbot.chat_stream,
|
| 146 |
-
title="๐ฅข
|
| 147 |
-
description="์ ๋ฏธ๋์ด 2.0 ๊ธฐ๋ฐ ๋ฐ์ฐฌ๊ฐ๊ฒ ๊ณ ๊ฐ ์๋ด๋ด์
๋๋ค. ๊ถ๊ธํ ๊ฒ์ ๋ฌผ์ด๋ณด์ธ์!",
|
| 148 |
examples=[
|
| 149 |
"์ฃผ๋ฌธ์ ์ด๋ป๊ฒ ํ๋์?",
|
| 150 |
"ํฌ์ธํธ๋ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์?",
|
|
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
class KyungAhNeChatbot:
|
| 6 |
def __init__(self):
|
| 7 |
# ํ๊น
ํ์ด์ค ์คํ์ด์ค์์๋ secrets์์ API ํค ๊ฐ์ ธ์ค๊ธฐ
|
| 8 |
api_key = os.getenv("GEMINI_API_KEY")
|
|
|
|
| 13 |
genai.configure(api_key=api_key)
|
| 14 |
self.model = genai.GenerativeModel('gemini-2.0-flash-exp')
|
| 15 |
|
| 16 |
+
# ๊ฒฝ์๋ค ๋ฐ์ฐฌ๊ฐ๊ฒ FAQ ๋ฐ์ดํฐ
|
| 17 |
self.faq_data = """
|
| 18 |
+
๊ฒฝ์๋ค ๋ฐ์ฐฌ๊ฐ๊ฒ ๊ณ ๊ฐ์ผํฐ FAQ:
|
| 19 |
|
| 20 |
== ๊ธฐ๋ณธ ์ ๋ณด ==
|
| 21 |
โข ๊ณ ๊ฐ์ผํฐ: 010-8082-0047
|
|
|
|
| 103 |
|
| 104 |
def chat_stream(self, message, history):
|
| 105 |
system_prompt = f"""
|
| 106 |
+
๋น์ ์ ๊ฒฝ์๋ค ๋ฐ์ฐฌ๊ฐ๊ฒ์ ์น์ ํ ์๋ด์์
๋๋ค.
|
| 107 |
|
| 108 |
{self.faq_data}
|
| 109 |
|
|
|
|
| 112 |
- FAQ์ ์๋ ๋ด์ฉ์ "์์ธํ ์ฌํญ์ ๊ณ ๊ฐ์ผํฐ(010-8082-0047)๋ก ๋ฌธ์ํด์ฃผ์ธ์"๋ผ๊ณ ์๋ดํด์ฃผ์ธ์
|
| 113 |
- ๋ฐ๋ง๋ณด๋ค๋ ์กด๋๋ง์ ์ฌ์ฉํด์ฃผ์ธ์
|
| 114 |
- ๊ฐ๊ฒฐํ๊ณ ์ดํดํ๊ธฐ ์ฝ๊ฒ ๋ต๋ณํด์ฃผ์ธ์
|
| 115 |
+
- "์๋
ํ์ธ์ ๊ฒฝ์๋ค์
๋๋ค"๋ก ์์ํ๊ณ "๊ฐ์ฌํฉ๋๋ค"๋ก ๋ง๋ฌด๋ฆฌํด์ฃผ์ธ์
|
| 116 |
"""
|
| 117 |
|
| 118 |
print(f"์ฌ์ฉ์ ์ง๋ฌธ: {message}")
|
|
|
|
| 138 |
|
| 139 |
# ์ฑ๋ด ์ธ์คํด์ค ์์ฑ
|
| 140 |
try:
|
| 141 |
+
chatbot = KyungAhNeChatbot()
|
| 142 |
|
| 143 |
# ๊ทธ๋ผ๋์ค ์ธํฐํ์ด์ค
|
| 144 |
demo = gr.ChatInterface(
|
| 145 |
fn=chatbot.chat_stream,
|
| 146 |
+
title="๐ฅข ๊ฒฝ์๋ค AI ์๋ด๋ด",
|
| 147 |
+
description="์ ๋ฏธ๋์ด 2.0 ๊ธฐ๋ฐ ๊ฒฝ์๋ค ๋ฐ์ฐฌ๊ฐ๊ฒ ๊ณ ๊ฐ ์๋ด๋ด์
๋๋ค. ๊ถ๊ธํ ๊ฒ์ ๋ฌผ์ด๋ณด์ธ์!",
|
| 148 |
examples=[
|
| 149 |
"์ฃผ๋ฌธ์ ์ด๋ป๊ฒ ํ๋์?",
|
| 150 |
"ํฌ์ธํธ๋ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์?",
|