Spaces:
Build error
Build error
Update app.py
Browse files
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 |
+
|