Spaces:
Running
Running
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -35,11 +35,8 @@ class MyClient(discord.Client):
|
|
35 |
def __init__(self, *args, **kwargs):
|
36 |
super().__init__(*args, **kwargs)
|
37 |
self.is_processing = False
|
38 |
-
|
39 |
-
|
40 |
-
logging.info(f'{self.user}๋ก ๋ก๊ทธ์ธ๋์์ต๋๋ค!')
|
41 |
-
subprocess.Popen(["python", "web.py"])
|
42 |
-
logging.info("Web.py server has been started.")
|
43 |
|
44 |
async def on_message(self, message):
|
45 |
if message.author == self.user:
|
@@ -61,18 +58,12 @@ class MyClient(discord.Client):
|
|
61 |
finally:
|
62 |
self.is_processing = False
|
63 |
|
64 |
-
def is_message_in_specific_channel(self, message):
|
65 |
-
return message.channel.id == SPECIFIC_CHANNEL_ID or (
|
66 |
-
isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
|
67 |
-
)
|
68 |
-
|
69 |
-
def is_math_question(self, content):
|
70 |
-
return bool(re.search(r'\b(solve|equation|calculate|math)\b', content, re.IGNORECASE))
|
71 |
-
|
72 |
async def handle_math_question(self, question):
|
73 |
-
loop
|
74 |
-
response = await
|
75 |
math_response = response[0]['generated_text']
|
|
|
|
|
76 |
|
77 |
# QuickLaTeX API๋ฅผ ์ด์ฉํ์ฌ LaTeX ์์์ ์ด๋ฏธ์ง๋ก ๋ณํ
|
78 |
data = {
|
|
|
35 |
def __init__(self, *args, **kwargs):
|
36 |
super().__init__(*args, **kwargs)
|
37 |
self.is_processing = False
|
38 |
+
# ์ํ ์ ๋ฌธ LLM ํ์ดํ๋ผ์ธ์ ์ธ์คํด์ค ๋ณ์๋ก ์ด๊ธฐํ
|
39 |
+
self.math_pipe = pipeline("text-generation", model="AI-MO/NuminaMath-7B-TIR")
|
|
|
|
|
|
|
40 |
|
41 |
async def on_message(self, message):
|
42 |
if message.author == self.user:
|
|
|
58 |
finally:
|
59 |
self.is_processing = False
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
async def handle_math_question(self, question):
|
62 |
+
# asyncio์ event loop๋ฅผ ์ฌ์ฉํ์ฌ math_pipe ํธ์ถ
|
63 |
+
response = await asyncio.get_event_loop().run_in_executor(None, lambda: self.math_pipe([{"role": "user", "content": question}]))
|
64 |
math_response = response[0]['generated_text']
|
65 |
+
|
66 |
+
# ์ดํ ์ฝ๋๋ ๋์ผํ๊ฒ ์ ์งํฉ๋๋ค.
|
67 |
|
68 |
# QuickLaTeX API๋ฅผ ์ด์ฉํ์ฌ LaTeX ์์์ ์ด๋ฏธ์ง๋ก ๋ณํ
|
69 |
data = {
|