Radosław Wolnik commited on
Commit
8a3cd96
·
1 Parent(s): ec0fe96

GENERATING AGAIN

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. ChatAI/chat_ai.py +1 -1
  3. app.py +43 -23
  4. discord.py +0 -9
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  /.idea/
2
  /.Chatter/
3
  .aider*
 
 
1
  /.idea/
2
  /.Chatter/
3
  .aider*
4
+ .env
ChatAI/chat_ai.py CHANGED
@@ -1,4 +1,4 @@
1
  from transformers import pipeline
2
 
3
 
4
- pipe = pipeline("text-generation", model="microsoft/phi-2")
 
1
  from transformers import pipeline
2
 
3
 
4
+ pipe = pipeline( model="facebook/blenderbot-400M-distill")
app.py CHANGED
@@ -1,9 +1,21 @@
1
- <<<<<<< SEARCH
2
- @bot.command
 
 
 
 
 
 
 
 
 
 
 
 
3
  async def on_message(message):
4
  guild = message.guild # Get the guild (server) the message is from
5
  channel = discord.utils.get(guild.text_channels, name="ai_chatter")
6
-
7
  # Verification
8
  if message.channel != channel: return;
9
  if message.author.bot: return;
@@ -16,25 +28,33 @@ async def on_message(message):
16
  print(message_counts[message.channel.id])
17
 
18
  messages = []
19
- logging.info("Initializing")
20
- channel = discord.utils.get(guild.text_channels, name="ai_chatter")
21
- if channel:
22
- print(f"Channel found: {channel.name}")
23
- =======
24
- @bot.command
25
- async def on_message(message):
26
- # Get the guild (server) the message is from
27
- guild = message.guild
28
- channel = discord.utils.get(guild.text_channels, name="ai_chatter")
29
-
30
- # Verification
31
- if message.channel != channel: return;
32
- if message.author.bot: return;
33
 
34
- # Track message count
35
- global message_count
36
- message_count += 1
37
- print(f"Message {message_count} in {channel.name}")
38
 
39
- messages = []
40
- >>>>>>> REPLACE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import discord
2
+ from discord.ext import commands
3
+ from ChatAI.chat_ai import pipe as ai
4
+
5
+
6
+ # Set up Discord bot intents and command prefix
7
+ intents = discord.Intents.default()
8
+ intents.message_content = True
9
+ intents.messages = True
10
+ bot = commands.Bot(command_prefix="!", intents=intents)
11
+ # Dictionary to track message count per channel
12
+ message_counts = {}
13
+
14
+ @bot.event
15
  async def on_message(message):
16
  guild = message.guild # Get the guild (server) the message is from
17
  channel = discord.utils.get(guild.text_channels, name="ai_chatter")
18
+
19
  # Verification
20
  if message.channel != channel: return;
21
  if message.author.bot: return;
 
28
  print(message_counts[message.channel.id])
29
 
30
  messages = []
31
+ if message_counts[message.channel.id] >= 4: # Check if the count reaches 10
32
+ async for message in channel.history(limit=4):
33
+ messages.append(message.content)
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ response = ai("\n".join(messages), max_length=1900, truncation=True, pad_token_id=50256)
 
 
 
36
 
37
+ await channel.send(response[0]['generated_text'])
38
+
39
+
40
+ message_counts[message.channel.id] = 0 # Reset the counter
41
+
42
+
43
+ await bot.process_commands(message) # Ensure commands still work
44
+
45
+ @bot.event
46
+ async def on_ready():
47
+ print(f'Logged in as {bot.user}') # Logs bot login in console
48
+
49
+ guild = discord.utils.get(bot.guilds, name="PrzebieralniaKoedukacyjna")
50
+ if guild:
51
+ # Get the channel by name
52
+ channel = discord.utils.get(guild.channels, name="ai_chatter")
53
+ if channel:
54
+ print(f"Channel found: {channel.name} (ID: {channel.id})")
55
+ else:
56
+ print("Channel not found!")
57
+
58
+ await channel.send(f"{bot.user} logged in, runnin on 'huggingface.co/spaces")
59
+
60
+ bot.run("MTMzODQ4NTY2MzY3MDA3OTQ4OA.GlmK1T.7ZeEiDz7ViY3zvuSqlacVocDMSZ-ln80c09AS4")
discord.py DELETED
@@ -1,9 +0,0 @@
1
- <<<<<<< SEARCH
2
- from discord.ext import commands
3
- from transformers import PreTrainedModel, PreTrained
4
- from ChatAI.chat_ai import pipe as ai
5
- =======
6
- from discord.ext import commands
7
- from transformers import PreTrainedModel, PreTrained
8
- from discord import Webhook
9
- >>>>>>> REPLACE