lunarflu HF Staff commited on
Commit
29fc37a
·
1 Parent(s): cb77456

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (2) hide show
  1. app.py +30 -13
  2. requirements.txt +1 -1
app.py CHANGED
@@ -2,14 +2,10 @@ import asyncio
2
  import glob
3
  import os
4
  import random
5
- import os
6
- import random
7
  import threading
8
- from discord import app_commands
9
  from discord.ext import commands
10
  import discord
11
  import gradio as gr
12
- import discord
13
  from gradio_client import Client
14
 
15
 
@@ -17,17 +13,19 @@ HF_TOKEN = os.getenv("HF_TOKEN")
17
  wuerstchen_client = Client("huggingface-projects/Wuerstchen-duplicate", HF_TOKEN)
18
  DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
19
 
20
- #---------------------------------------------------------------------------------------------------------------------
21
  intents = discord.Intents.all()
22
  bot = commands.Bot(command_prefix="/", intents=intents)
23
- #---------------------------------------------------------------------------------------------------------------------
 
24
  @bot.event
25
  async def on_ready():
26
  print(f"Logged in as {bot.user} (ID: {bot.user.id})")
27
  synced = await bot.tree.sync()
28
  print(f"Synced commands: {', '.join([s.name for s in synced])}.")
29
  print("------")
30
- #---------------------------------------------------------------------------------------------------------------------
 
31
  @bot.hybrid_command(
32
  name="wuerstchen",
33
  description="Enter a prompt to generate art!",
@@ -72,7 +70,7 @@ def wuerstchen_inference(prompt):
72
  async def run_wuerstchen(ctx, prompt):
73
  """Responds to /Wuerstchen command"""
74
  try:
75
- message = await ctx.send(f"**{prompt}** - {ctx.author.mention} <a:loading:1114111677990981692>")
76
 
77
  loop = asyncio.get_running_loop()
78
  result_path = await loop.run_in_executor(None, wuerstchen_inference, prompt)
@@ -90,13 +88,32 @@ def run_bot():
90
 
91
  threading.Thread(target=run_bot).start()
92
  """This allows us to run the Discord bot in a Python thread"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  with gr.Blocks() as demo:
94
- gr.Markdown("""
95
- # Huggingbots Server
96
- This space hosts the huggingbots discord bot.
97
- Currently supported models are Falcon and DeepfloydIF
98
- https://discord.com/api/oauth2/authorize?client_id=1155489509518098565&permissions=51200&scope=bot
99
  """)
 
 
100
  demo.queue(concurrency_count=100)
101
  demo.queue(max_size=100)
102
  demo.launch()
 
2
  import glob
3
  import os
4
  import random
 
 
5
  import threading
 
6
  from discord.ext import commands
7
  import discord
8
  import gradio as gr
 
9
  from gradio_client import Client
10
 
11
 
 
13
  wuerstchen_client = Client("huggingface-projects/Wuerstchen-duplicate", HF_TOKEN)
14
  DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
15
 
16
+
17
  intents = discord.Intents.all()
18
  bot = commands.Bot(command_prefix="/", intents=intents)
19
+
20
+
21
  @bot.event
22
  async def on_ready():
23
  print(f"Logged in as {bot.user} (ID: {bot.user.id})")
24
  synced = await bot.tree.sync()
25
  print(f"Synced commands: {', '.join([s.name for s in synced])}.")
26
  print("------")
27
+
28
+
29
  @bot.hybrid_command(
30
  name="wuerstchen",
31
  description="Enter a prompt to generate art!",
 
70
  async def run_wuerstchen(ctx, prompt):
71
  """Responds to /Wuerstchen command"""
72
  try:
73
+ message = await ctx.send(f"**{prompt}** - {ctx.author.mention} (generating...)")
74
 
75
  loop = asyncio.get_running_loop()
76
  result_path = await loop.run_in_executor(None, wuerstchen_inference, prompt)
 
88
 
89
  threading.Thread(target=run_bot).start()
90
  """This allows us to run the Discord bot in a Python thread"""
91
+
92
+
93
+ welcome_message = """
94
+ ## Add this bot to your server by clicking this link:
95
+
96
+ https://discord.com/api/oauth2/authorize?client_id=1155489509518098565&permissions=51200&scope=bot
97
+
98
+ ## How to use it?
99
+
100
+ The bot can be triggered via `/wuerstchen` followed by your text prompt.
101
+
102
+ This will generate an image based on your prompt, which is then posted in the channel!
103
+
104
+ ⚠️ Note ⚠️: Please make sure this bot's command does have the same name as another command in your server.
105
+
106
+ ⚠️ Note ⚠️: Bot commands do not work in DMs with the bot as of now.
107
+ """
108
+
109
+
110
  with gr.Blocks() as demo:
111
+ gr.Markdown(f"""
112
+ # Discord bot of https://huggingface.co/spaces/warp-ai/Wuerstchen
113
+ {welcome_message}
 
 
114
  """)
115
+
116
+
117
  demo.queue(concurrency_count=100)
118
  demo.queue(max_size=100)
119
  demo.launch()
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
  discord.py
2
- gradio
 
1
  discord.py
2
+ gradio