Update app.py
Browse files
app.py
CHANGED
|
@@ -115,40 +115,26 @@ class SimpleBanchanChatbot:
|
|
| 115 |
- ์ธ์ฌ๋ง๋ก ์์ํ๊ณ ๊ฐ์ฌ์ธ์ฌ๋ก ๋ง๋ฌด๋ฆฌํด์ฃผ์ธ์
|
| 116 |
"""
|
| 117 |
|
|
|
|
|
|
|
|
|
|
| 118 |
try:
|
| 119 |
response = self.model.generate_content(
|
| 120 |
-
contents=f"{system_prompt}\n\n์ฌ์ฉ์ ์ง๋ฌธ: {message}"
|
| 121 |
-
generation_config=genai.GenerationConfig(
|
| 122 |
-
temperature=0.1,
|
| 123 |
-
max_output_tokens=1000,
|
| 124 |
-
),
|
| 125 |
-
stream=True
|
| 126 |
)
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
if chunk.text:
|
| 132 |
-
partial_message += chunk.text
|
| 133 |
-
yield partial_message
|
| 134 |
-
except:
|
| 135 |
-
continue
|
| 136 |
-
|
| 137 |
except Exception as e:
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
stream=False
|
| 147 |
-
)
|
| 148 |
-
yield response.text
|
| 149 |
-
except Exception as fallback_error:
|
| 150 |
-
print(f"Fallback ์๋ฌ: {str(fallback_error)}")
|
| 151 |
-
yield f"์ฃ์กํฉ๋๋ค. ์์คํ
์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๊ณ ๊ฐ์ผํฐ(010-8082-0047)๋ก ์ฐ๋ฝํด์ฃผ์ธ์."
|
| 152 |
|
| 153 |
# ์ฑ๋ด ์ธ์คํด์ค ์์ฑ
|
| 154 |
try:
|
|
|
|
| 115 |
- ์ธ์ฌ๋ง๋ก ์์ํ๊ณ ๊ฐ์ฌ์ธ์ฌ๋ก ๋ง๋ฌด๋ฆฌํด์ฃผ์ธ์
|
| 116 |
"""
|
| 117 |
|
| 118 |
+
print(f"์ฌ์ฉ์ ์ง๋ฌธ: {message}")
|
| 119 |
+
print(f"API ํค ์ํ: {'์ค์ ๋จ' if os.getenv('GEMINI_API_KEY') else '์์'}")
|
| 120 |
+
|
| 121 |
try:
|
| 122 |
response = self.model.generate_content(
|
| 123 |
+
contents=f"{system_prompt}\n\n์ฌ์ฉ์ ์ง๋ฌธ: {message}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
)
|
| 125 |
|
| 126 |
+
print(f"์๋ต ๋ฐ์: {response.text[:100]}...")
|
| 127 |
+
yield response.text
|
| 128 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
except Exception as e:
|
| 130 |
+
error_msg = str(e)
|
| 131 |
+
print(f"์๋ฌ ๋ฐ์: {error_msg}")
|
| 132 |
+
|
| 133 |
+
yield f"""์ฃ์กํฉ๋๋ค. ๊ธฐ์ ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
|
| 134 |
+
|
| 135 |
+
์๋ฌ ์ ๋ณด: {error_msg}
|
| 136 |
+
|
| 137 |
+
๊ณ ๊ฐ์ผํฐ(010-8082-0047)๋ก ์ฐ๋ฝํด์ฃผ์ธ์."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
# ์ฑ๋ด ์ธ์คํด์ค ์์ฑ
|
| 140 |
try:
|