seawolf2357 commited on
Commit
672b059
β€’
1 Parent(s): 1e4bf1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -7,7 +7,7 @@ import asyncio
7
  import subprocess
8
 
9
  # λ‘œκΉ… μ„€μ •
10
- logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(name)s: %(message)s', handlers=[logging.StreamHandler()])
11
 
12
  # μΈν…νŠΈ μ„€μ •
13
  intents = discord.Intents.default()
@@ -39,6 +39,11 @@ class MyClient(discord.Client):
39
  subprocess.Popen(["python", "web.py"])
40
  logging.info("Web.py server has been started.")
41
 
 
 
 
 
 
42
  async def on_message(self, message):
43
  if message.author == self.user:
44
  return
@@ -82,13 +87,8 @@ async def extract_keywords(message):
82
  response = await loop.run_in_executor(None, lambda: hf_client.chat_completion(
83
  messages, max_tokens=10, temperature=0.7, top_p=0.85))
84
 
85
- full_response = []
86
- for part in response:
87
- logging.debug(f'Part received from stream: {part}')
88
- if part.choices and part.choices[0].delta and part.choices[0].delta.content:
89
- full_response.append(part.choices[0].delta.content)
90
-
91
- keywords = ''.join(full_response).strip()
92
  logging.debug(f'Extracted keywords: {keywords}')
93
  return keywords
94
 
 
7
  import subprocess
8
 
9
  # λ‘œκΉ… μ„€μ •
10
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(name)s:%(message)s', handlers=[logging.StreamHandler()])
11
 
12
  # μΈν…νŠΈ μ„€μ •
13
  intents = discord.Intents.default()
 
39
  subprocess.Popen(["python", "web.py"])
40
  logging.info("Web.py server has been started.")
41
 
42
+ # 봇이 μ‹œμž‘λ  λ•Œ μ•ˆλ‚΄ λ©”μ‹œμ§€λ₯Ό 전솑
43
+ channel = self.get_channel(SPECIFIC_CHANNEL_ID)
44
+ if channel:
45
+ await channel.send("찾고싢은 사진에 λŒ€ν•œ μ„€λͺ…을 ν•œ λ¬Έμž₯ λ‹¨μœ„λ‘œ μž…λ ₯ν•˜μ„Έμš”. 예) λˆˆλ°­μ— λ›°μ–΄ 놀고 μžˆλŠ” ν—ˆμŠ€ν‚€")
46
+
47
  async def on_message(self, message):
48
  if message.author == self.user:
49
  return
 
87
  response = await loop.run_in_executor(None, lambda: hf_client.chat_completion(
88
  messages, max_tokens=10, temperature=0.7, top_p=0.85))
89
 
90
+ # LLM 응닡은 ν…μŠ€νŠΈμΌ 수 μžˆμœΌλ―€λ‘œ λ‹¨μˆœνžˆ κ²°ν•©ν•˜μ—¬ λ°˜ν™˜
91
+ keywords = response.strip()
 
 
 
 
 
92
  logging.debug(f'Extracted keywords: {keywords}')
93
  return keywords
94