seawolf2357 commited on
Commit
b4a00e6
โ€ข
1 Parent(s): 2abbdfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -76,9 +76,10 @@ class MyClient(discord.Client):
76
  self.is_processing = True
77
  try:
78
  response = await generate_response(message)
79
- if response and response.strip() == "":
80
- response = "์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค, ์ œ๊ณตํ•  ์ˆ˜ ์žˆ๋Š” ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
81
- await message.channel.send(response)
 
82
  finally:
83
  self.is_processing = False
84
  logging.debug("Message processing completed, ready for the next one.")
@@ -103,12 +104,17 @@ async def generate_response(message):
103
  else:
104
  system_message = f"{user_mention}, ๊ด€๋ จ ๋ฒ•๋ฅ  ์ •๋ณด๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
105
 
106
- # ์‘๋‹ต ๋ณด๋‚ด๊ธฐ
107
- await message.channel.send(system_message)
108
- logging.debug(f'Full model response sent: {system_message}')
109
- conversation_history.append({"role": "assistant", "content": system_message})
 
 
 
 
 
 
110
 
111
  if __name__ == "__main__":
112
  discord_client = MyClient(intents=intents)
113
  discord_client.run(os.getenv('DISCORD_TOKEN'))
114
-
 
76
  self.is_processing = True
77
  try:
78
  response = await generate_response(message)
79
+ if response and response.strip():
80
+ await message.channel.send(response)
81
+ else:
82
+ await message.channel.send("์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค, ์ œ๊ณตํ•  ์ˆ˜ ์žˆ๋Š” ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.")
83
  finally:
84
  self.is_processing = False
85
  logging.debug("Message processing completed, ready for the next one.")
 
104
  else:
105
  system_message = f"{user_mention}, ๊ด€๋ จ ๋ฒ•๋ฅ  ์ •๋ณด๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
106
 
107
+ # ๋ฉ”์‹œ์ง€ ๊ธธ์ด ์ œํ•œ ์ฒ˜๋ฆฌ
108
+ max_length = 2000
109
+ if len(system_message) > max_length:
110
+ response_parts = []
111
+ for i in range(0, len(system_message), max_length):
112
+ part_response = system_message[i:i + max_length]
113
+ await message.channel.send(part_response)
114
+ response_parts.append(part_response)
115
+ return response_parts[0] if response_parts else "์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค, ์ œ๊ณตํ•  ์ˆ˜ ์žˆ๋Š” ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
116
+ return system_message
117
 
118
  if __name__ == "__main__":
119
  discord_client = MyClient(intents=intents)
120
  discord_client.run(os.getenv('DISCORD_TOKEN'))