Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -89,14 +89,17 @@ class MyClient(discord.Client):
|
|
89 |
|
90 |
self.is_processing = True
|
91 |
try:
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
97 |
else:
|
98 |
-
|
99 |
-
await self.send_message_with_latex(thread, response)
|
100 |
finally:
|
101 |
self.is_processing = False
|
102 |
|
@@ -197,9 +200,8 @@ class MyClient(discord.Client):
|
|
197 |
logging.warning(f"503 error encountered. Retrying in {delay} seconds...")
|
198 |
await asyncio.sleep(delay)
|
199 |
else:
|
200 |
-
logging.warning("Switching to secondary model due to
|
201 |
self.hf_client = hf_client_secondary
|
202 |
-
await asyncio.sleep(delay)
|
203 |
else:
|
204 |
raise
|
205 |
|
|
|
89 |
|
90 |
self.is_processing = True
|
91 |
try:
|
92 |
+
if isinstance(message.channel, discord.TextChannel):
|
93 |
+
# 새로운 스레드 생성
|
94 |
+
thread = await message.channel.create_thread(name=f"질문: {message.author.name}", message=message)
|
95 |
+
if self.is_math_question(message.content):
|
96 |
+
text_response = await self.handle_math_question(message.content)
|
97 |
+
await self.send_message_with_latex(thread, text_response)
|
98 |
+
else:
|
99 |
+
response = await self.generate_response(message)
|
100 |
+
await self.send_message_with_latex(thread, response)
|
101 |
else:
|
102 |
+
logging.warning("Message is not in a TextChannel.")
|
|
|
103 |
finally:
|
104 |
self.is_processing = False
|
105 |
|
|
|
200 |
logging.warning(f"503 error encountered. Retrying in {delay} seconds...")
|
201 |
await asyncio.sleep(delay)
|
202 |
else:
|
203 |
+
logging.warning("Switching to secondary model due to persistent 503 errors.")
|
204 |
self.hf_client = hf_client_secondary
|
|
|
205 |
else:
|
206 |
raise
|
207 |
|