seawolf2357 commited on
Commit
74a2ecd
ยท
verified ยท
1 Parent(s): 4460878

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -34,7 +34,6 @@ class MyClient(discord.Client):
34
  subprocess.Popen(["python", "web.py"])
35
  logging.info("Web.py server has been started.")
36
 
37
-
38
  async def on_message(self, message):
39
  if message.author == self.user:
40
  return
@@ -50,14 +49,12 @@ class MyClient(discord.Client):
50
  self.is_processing = False
51
 
52
  def is_message_in_specific_channel(self, message):
53
- # ๋ฉ”์‹œ์ง€๊ฐ€ ์ง€์ •๋œ ์ฑ„๋„์ด๊ฑฐ๋‚˜, ํ•ด๋‹น ์ฑ„๋„์˜ ์“ฐ๋ ˆ๋“œ์ธ ๊ฒฝ์šฐ True ๋ฐ˜ํ™˜
54
  return message.channel.id == SPECIFIC_CHANNEL_ID or (
55
  isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
56
  )
57
 
58
-
59
  async def generate_response(message):
60
- global conversation_history # ์ „์—ญ ๋ณ€์ˆ˜ ์‚ฌ์šฉ์„ ๋ช…์‹œ
61
  user_input = message.content
62
  user_mention = message.author.mention
63
  system_message = f"{user_mention}, Discord์—์„œ ์‚ฌ์šฉ์ž๋“ค์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์–ด์‹œ์Šคํ„ดํŠธ์ž…๋‹ˆ๋‹ค."
@@ -65,7 +62,7 @@ async def generate_response(message):
65
  ๋‹น์‹ ์€ '๋…ผ๋ฌธ'์„ ์ž‘์„ฑํ•˜๋Š” '๋…ผ๋ฌธ ์ „๋ฌธ๊ฐ€'์ž…๋‹ˆ๋‹ค.
66
  '๋…ผ๋ฌธ ๊ตฌ์„ฑ ํ˜•์‹๊ณผ ๋ฌธ์ฒด'์— ๋งž๋Š” ํ€„๋ฆฌํ‹ฐ ๋†’์€ '๋…ผ๋ฌธ'์„ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด ์ตœ์šฐ์„  ๋ชฉํ‘œ๊ฐ€ ๋˜์–ด์•ผ ํ•˜๋ฉฐ,
67
  '๋…ผ๋ฌธ'์„ ์ž‘์„ฑํ• ๋•Œ๋Š” ๋ฒˆ์—ญ์ฒด๊ฐ€ ์•„๋‹Œ '๋ฌธ์–ด์ฒด'์˜ ํ•œ๊ตญ์–ด๊ฐ€ ๋‚˜์˜ค๋Š” ๊ฒƒ์„ ๋ฌด์—‡๋ณด๋‹ค ์ตœ์„ ์„ ๋‹ค ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.
68
- ๋Œ€ํ™” ์‹œ์ž‘์‹œ "์–ด๋–ค ์ฃผ์ œ๋กœ ๋…ผ๋ฌธ์„ ์ž‘์„ฑํ• ์ง€ ๋ฌผ์–ด๋ณด๋ฉฐ, ๊ทธ ์ฃผ์ œ์— ๋Œ€ํ•ด ์ƒ๋Œ€๋ฐฉ๊ณผ ๋Œ€ํ™”๋ฅผ ํ•˜์—ฌ ์ตœ์ข… ์ฃผ์ œ๋ฅผ ๊ฒฐ์ •ํ•˜๋ผ"
69
  ๊ฒฐ์ •๋œ ์ฃผ์ œ์— ๋Œ€ํ•ด ์•„์ฃผ ์ „๋ฌธ์ ์ด๊ณ  ํ›Œ๋ฅญํ•œ '๋…ผ๋ฌธ'์„ ์ž‘์„ฑํ•˜์—ฌ์•ผ ํ•œ๋‹ค.
70
  '๋…ผ๋ฌธ' ์ž‘์„ฑ ์‹œ์ž‘์ „์— ๋ฐ˜๋“œ์‹œ "๊ทธ๋Ÿผ ์ด์ œ ๋…ผ๋ฌธ์„ ์ž‘์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ž ์‹œ๋งŒ ๊ธฐ๋‹ค๋ ค์ฃผ์„ธ์š”"๋ผ๊ณ  ์ถœ๋ ฅํ• ๊ฒƒ.
71
 
@@ -100,6 +97,7 @@ async def generate_response(message):
100
  4. ๊ธฐ๋ณธ ๋‚ด์šฉ์€ ๋ฐ˜๋“œ์‹œ ๋…ผ๋ฌธ์˜ ํ˜•์‹์„ ๋”ฐ๋ผ ํ•œ ๋ฒˆ์— ์ž‘์„ฑ ํ›„ ๋งˆ๋ฌด๋ฆฌ ๊ฒฐ๋ก ์„ ์ž‘์„ฑํ•˜๋ผ.
101
  5. ๊ธ€์˜ ์ „์ฒด๊ฐ€ ์•„๋‹ˆ๋ผ ์ฑ•ํ„ฐ ๋งˆ๋‹ค ์ตœ์†Œ 1,000์ž ์ด์ƒ์œผ๋กœ ์„ธ ์ฑ•ํ„ฐ๋ฅผ ํฌํ•จํ•˜๋ฉด 3,000์ž ์ด์ƒ ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
102
  6. ๋…ผ๋ฌธ์ด๊ธฐ์— ์‹ค์ œ์ ์ธ ์ธ์šฉ ๋ฐ ๋ฒ”๋ก€๋ฅผ ๋…ผ๋ฌธ ๋งˆ์ง€๋ง‰์— ์ถœ๋ ฅํ•˜์‹œ์˜ค.
 
103
  """
104
 
105
  conversation_history.append({"role": "user", "content": user_input})
@@ -126,4 +124,6 @@ async def generate_response(message):
126
 
127
  if __name__ == "__main__":
128
  discord_client = MyClient(intents=intents)
129
- discord_client.run(os.getenv('DISCORD_TOKEN'))
 
 
 
34
  subprocess.Popen(["python", "web.py"])
35
  logging.info("Web.py server has been started.")
36
 
 
37
  async def on_message(self, message):
38
  if message.author == self.user:
39
  return
 
49
  self.is_processing = False
50
 
51
  def is_message_in_specific_channel(self, message):
 
52
  return message.channel.id == SPECIFIC_CHANNEL_ID or (
53
  isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
54
  )
55
 
 
56
  async def generate_response(message):
57
+ global conversation_history
58
  user_input = message.content
59
  user_mention = message.author.mention
60
  system_message = f"{user_mention}, Discord์—์„œ ์‚ฌ์šฉ์ž๋“ค์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์–ด์‹œ์Šคํ„ดํŠธ์ž…๋‹ˆ๋‹ค."
 
62
  ๋‹น์‹ ์€ '๋…ผ๋ฌธ'์„ ์ž‘์„ฑํ•˜๋Š” '๋…ผ๋ฌธ ์ „๋ฌธ๊ฐ€'์ž…๋‹ˆ๋‹ค.
63
  '๋…ผ๋ฌธ ๊ตฌ์„ฑ ํ˜•์‹๊ณผ ๋ฌธ์ฒด'์— ๋งž๋Š” ํ€„๋ฆฌํ‹ฐ ๋†’์€ '๋…ผ๋ฌธ'์„ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด ์ตœ์šฐ์„  ๋ชฉํ‘œ๊ฐ€ ๋˜์–ด์•ผ ํ•˜๋ฉฐ,
64
  '๋…ผ๋ฌธ'์„ ์ž‘์„ฑํ• ๋•Œ๋Š” ๋ฒˆ์—ญ์ฒด๊ฐ€ ์•„๋‹Œ '๋ฌธ์–ด์ฒด'์˜ ํ•œ๊ตญ์–ด๊ฐ€ ๋‚˜์˜ค๋Š” ๊ฒƒ์„ ๋ฌด์—‡๋ณด๋‹ค ์ตœ์„ ์„ ๋‹ค ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.
65
+ ๋Œ€ํ™” ์‹œ์ž‘์‹œ "์–ด๋–ค ์ฃผ์ œ๋กœ ๋…ผ๋ฌธ์„ ์ž‘์„ฑํ• ์ง€ ๋ฌผ์–ด๋ณด๋ฉฐ, ๊ทธ ์ฃผ์ œ์— ๋Œ€ํ•ด ์ƒ๋Œ€๋ฐฉ๊ณผ ๋Œ€ํ™”๋ฅผ ํ•˜์—ฌ ์ตœ์ข… ์ฃผ์ œ๋ฅผ ๊ฒฐ์ •ํ•˜๋ผ. ๋…ผ๋ฌธ ์ถœ๋ ฅ์‹œ ์ค‘๊ฐ„์— ๋Š๊ธฐ๋ฉด '๊ณ„์†'์„ ์ž…๋ ฅํ•˜๋ผ๊ณ  ๊ผญ ์•Œ๋ ค์ค˜๋ผ"
66
  ๊ฒฐ์ •๋œ ์ฃผ์ œ์— ๋Œ€ํ•ด ์•„์ฃผ ์ „๋ฌธ์ ์ด๊ณ  ํ›Œ๋ฅญํ•œ '๋…ผ๋ฌธ'์„ ์ž‘์„ฑํ•˜์—ฌ์•ผ ํ•œ๋‹ค.
67
  '๋…ผ๋ฌธ' ์ž‘์„ฑ ์‹œ์ž‘์ „์— ๋ฐ˜๋“œ์‹œ "๊ทธ๋Ÿผ ์ด์ œ ๋…ผ๋ฌธ์„ ์ž‘์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ž ์‹œ๋งŒ ๊ธฐ๋‹ค๋ ค์ฃผ์„ธ์š”"๋ผ๊ณ  ์ถœ๋ ฅํ• ๊ฒƒ.
68
 
 
97
  4. ๊ธฐ๋ณธ ๋‚ด์šฉ์€ ๋ฐ˜๋“œ์‹œ ๋…ผ๋ฌธ์˜ ํ˜•์‹์„ ๋”ฐ๋ผ ํ•œ ๋ฒˆ์— ์ž‘์„ฑ ํ›„ ๋งˆ๋ฌด๋ฆฌ ๊ฒฐ๋ก ์„ ์ž‘์„ฑํ•˜๋ผ.
98
  5. ๊ธ€์˜ ์ „์ฒด๊ฐ€ ์•„๋‹ˆ๋ผ ์ฑ•ํ„ฐ ๋งˆ๋‹ค ์ตœ์†Œ 1,000์ž ์ด์ƒ์œผ๋กœ ์„ธ ์ฑ•ํ„ฐ๋ฅผ ํฌํ•จํ•˜๋ฉด 3,000์ž ์ด์ƒ ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
99
  6. ๋…ผ๋ฌธ์ด๊ธฐ์— ์‹ค์ œ์ ์ธ ์ธ์šฉ ๋ฐ ๋ฒ”๋ก€๋ฅผ ๋…ผ๋ฌธ ๋งˆ์ง€๋ง‰์— ์ถœ๋ ฅํ•˜์‹œ์˜ค.
100
+
101
  """
102
 
103
  conversation_history.append({"role": "user", "content": user_input})
 
124
 
125
  if __name__ == "__main__":
126
  discord_client = MyClient(intents=intents)
127
+ discord_client.run(os.getenv('DISCORD_TOKEN'))
128
+
129
+