seawolf2357 commited on
Commit
33a426d
ยท
verified ยท
1 Parent(s): d9ff808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -15
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
- async def on_ready(self):
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 = asyncio.get_event_loop()
74
- response = await loop.run_in_executor(None, lambda: self.math_pipe([{"role": "user", "content": question}]))
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 = {