Spaces:
Runtime error
Runtime error
Radosław Wolnik
commited on
Commit
·
f5e2b6b
1
Parent(s):
79f18b3
- .gitignore +2 -1
- ChatAI/__init__.py +0 -0
- ChatAI/chat_ai.py +4 -0
- README.md +0 -12
- app.py +62 -61
- requirements.txt +3 -1
.gitignore
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
/.idea/
|
2 |
-
/.Chatter/
|
|
|
|
1 |
/.idea/
|
2 |
+
/.Chatter/
|
3 |
+
.aider*
|
ChatAI/__init__.py
ADDED
File without changes
|
ChatAI/chat_ai.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
|
4 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-xxl")
|
README.md
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: DiscordChatter
|
3 |
-
emoji: 💬
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: purple
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.0.1
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -1,61 +1,62 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
from
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
1 |
+
import discord
|
2 |
+
from discord.ext import commands
|
3 |
+
from ChatAI.chat_ai import pipe as ai
|
4 |
+
|
5 |
+
# Set up Discord bot intents and command prefix
|
6 |
+
intents = discord.Intents.default()
|
7 |
+
intents.message_content = True
|
8 |
+
intents.messages = True
|
9 |
+
bot = commands.Bot(command_prefix="!", intents=intents)
|
10 |
+
|
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 = message.channel
|
18 |
+
if message.channel != discord.utils.get(guild.text_channels, name="ai_chatter"):
|
19 |
+
print("not ai_chatter channel"); return;
|
20 |
+
print("channel: ai_chatter")
|
21 |
+
|
22 |
+
if message.author.bot:
|
23 |
+
print("not taking own messages into count"); return;
|
24 |
+
|
25 |
+
if message.author.name!="sandra_n": pass;
|
26 |
+
print("I can see its you, sis"); await message.channel.send("I can see its you, sis")
|
27 |
+
|
28 |
+
if message.channel.id not in message_counts: # Ensure tracking exists for this channel
|
29 |
+
message_counts[message.channel.id] = 0
|
30 |
+
|
31 |
+
message_counts[message.channel.id] += 1 # Increment message count
|
32 |
+
print(message_counts[message.channel.id])
|
33 |
+
|
34 |
+
messages = []
|
35 |
+
if message_counts[message.channel.id] >= 4: # Check if the count reaches 10
|
36 |
+
async for message in channel.history(limit=4):
|
37 |
+
messages.append(message.content)
|
38 |
+
|
39 |
+
await message.channel.send("\n".join(messages))
|
40 |
+
|
41 |
+
|
42 |
+
message_counts[message.channel.id] = 0 # Reset the counter
|
43 |
+
|
44 |
+
|
45 |
+
await bot.process_commands(message) # Ensure commands still work
|
46 |
+
|
47 |
+
@bot.event
|
48 |
+
async def on_ready():
|
49 |
+
print(f'Logged in as {bot.user}') # Logs bot login in console
|
50 |
+
|
51 |
+
guild = discord.utils.get(bot.guilds, name="PrzebieralniaKoedukacyjna")
|
52 |
+
if guild:
|
53 |
+
# Get the channel by name
|
54 |
+
channel = discord.utils.get(guild.channels, name="ai_chatter") # Replace "general" with your channel name
|
55 |
+
if channel:
|
56 |
+
print(f"Channel found: {channel.name} (ID: {channel.id})")
|
57 |
+
else:
|
58 |
+
print("Channel not found!")
|
59 |
+
|
60 |
+
await channel.send(f"{bot.user} logged in, runnin on 'huggingface.co/spaces")
|
61 |
+
|
62 |
+
bot.run("MTMzODQ4NTY2MzY3MDA3OTQ4OA.GlmK1T.7ZeEiDz7ViY3zvuSqlacVocDMSZ-ln80c09AS4")
|
requirements.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
1 |
huggingface_hub==0.25.2
|
2 |
discord.py
|
3 |
-
discord
|
|
|
|
1 |
+
transformers
|
2 |
huggingface_hub==0.25.2
|
3 |
discord.py
|
4 |
+
discord
|
5 |
+
TensorFlow>=2.0
|