Spaces:
Runtime error
Runtime error
Radosław Wolnik
commited on
Commit
·
43176a0
1
Parent(s):
0650760
app.py
CHANGED
@@ -12,6 +12,7 @@ bot = commands.Bot(command_prefix="!", intents=intents)
|
|
12 |
# Dictionary to track message count per channel
|
13 |
message_counts = {}
|
14 |
|
|
|
15 |
@bot.event
|
16 |
async def on_message(message):
|
17 |
guild = message.guild # Get the guild (server) the message is from
|
@@ -29,19 +30,22 @@ async def on_message(message):
|
|
29 |
print(message_counts[message.channel.id])
|
30 |
|
31 |
messages = []
|
32 |
-
if message_counts[message.channel.id] >=
|
33 |
-
async for message in channel.history(limit=
|
34 |
messages.append(message.content)
|
35 |
-
|
36 |
previous_messages = ("\n".join(messages))
|
37 |
response = ai.text_generation(previous_messages, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0)
|
38 |
-
|
39 |
splited_response = split_string(response)
|
40 |
for part in splited_response:
|
41 |
await channel.send(part)
|
42 |
|
43 |
message_counts[message.channel.id] = 0 # Reset the counter
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
await bot.process_commands(message) # Ensure commands still work
|
46 |
|
47 |
def split_string(text: str) -> list[str]:
|
|
|
12 |
# Dictionary to track message count per channel
|
13 |
message_counts = {}
|
14 |
|
15 |
+
|
16 |
@bot.event
|
17 |
async def on_message(message):
|
18 |
guild = message.guild # Get the guild (server) the message is from
|
|
|
30 |
print(message_counts[message.channel.id])
|
31 |
|
32 |
messages = []
|
33 |
+
if message_counts[message.channel.id] >= 10: # Check if the count reaches 10
|
34 |
+
async for message in channel.history(limit=10):
|
35 |
messages.append(message.content)
|
|
|
36 |
previous_messages = ("\n".join(messages))
|
37 |
response = ai.text_generation(previous_messages, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0)
|
|
|
38 |
splited_response = split_string(response)
|
39 |
for part in splited_response:
|
40 |
await channel.send(part)
|
41 |
|
42 |
message_counts[message.channel.id] = 0 # Reset the counter
|
43 |
|
44 |
+
response = ai.text_generation(message, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0)
|
45 |
+
splited_response = split_string(response)
|
46 |
+
for part in splited_response:
|
47 |
+
await channel.send(part)
|
48 |
+
|
49 |
await bot.process_commands(message) # Ensure commands still work
|
50 |
|
51 |
def split_string(text: str) -> list[str]:
|