elasko-aim commited on
Commit
5000e38
·
verified ·
1 Parent(s): 35ac48f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -41
app.py CHANGED
@@ -1,61 +1,44 @@
1
  import os
 
2
  import discord
3
  import requests
 
4
  from discord.ext import commands
5
- from dotenv import load_dotenv
6
 
7
- # Завантажуємо токени
8
- load_dotenv()
9
  DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
10
  HF_API_TOKEN = os.getenv("HF_API_TOKEN")
11
  HF_TEXT_MODEL = os.getenv("HF_TEXT_MODEL")
12
  HF_IMAGE_MODEL = os.getenv("HF_IMAGE_MODEL")
13
 
14
- # Намір для команд
15
  intents = discord.Intents.default()
16
  bot = commands.Bot(command_prefix="/", intents=intents)
17
 
18
- # ==================== КОМАНДИ ====================
19
-
20
  @bot.event
21
  async def on_ready():
22
- print(f"🩸 CultCore активований як {bot.user}")
23
 
24
- @bot.command(name="initiate")
25
  async def initiate(ctx):
26
- await ctx.send("⚫ Initiation sequence... connection established. Welcome to the CultCore system.")
27
-
28
- @bot.command(name="signal")
29
- async def signal(ctx, *, prompt: str = "send me a mysterious signal"):
30
- await ctx.send("🔴 Receiving signal from the core...")
31
- response = requests.post(
32
- f"https://api-inference.huggingface.co/models/{HF_TEXT_MODEL}",
33
- headers={"Authorization": f"Bearer {HF_API_TOKEN}"},
34
- json={"inputs": prompt}
35
- )
36
- data = response.json()
37
- text_output = data[0]['generated_text'] if isinstance(data, list) else str(data)
38
- await ctx.send(f"🧠 Signal received:\n```{text_output[:1500]}```")
39
-
40
- @bot.command(name="create_image")
41
- async def create_image(ctx, *, prompt: str = "cultcore black red techno aesthetic"):
42
- await ctx.send("⚙️ Generating image through CultCore...")
43
- response = requests.post(
44
- f"https://api-inference.huggingface.co/models/{HF_IMAGE_MODEL}",
45
- headers={"Authorization": f"Bearer {HF_API_TOKEN}"},
46
- json={"inputs": prompt}
47
- )
48
- if response.status_code == 200:
49
- with open("output.png", "wb") as f:
50
- f.write(response.content)
51
- await ctx.send("🖤 Image generated:", file=discord.File("output.png"))
52
- else:
53
- await ctx.send("❌ Image generation failed. Check API token or model name.")
54
-
55
- @bot.command(name="status")
56
  async def status(ctx):
57
- await ctx.send("🩸 CultCore System Online.\nEnergy flow stable.\nAwaiting next signal...")
 
 
 
 
 
 
58
 
59
- # =================================================
 
60
 
61
- bot.run(DISCORD_TOKEN)
 
 
 
 
 
 
 
 
1
  import os
2
+ import threading
3
  import discord
4
  import requests
5
+ import gradio as gr
6
  from discord.ext import commands
 
7
 
 
 
8
  DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
9
  HF_API_TOKEN = os.getenv("HF_API_TOKEN")
10
  HF_TEXT_MODEL = os.getenv("HF_TEXT_MODEL")
11
  HF_IMAGE_MODEL = os.getenv("HF_IMAGE_MODEL")
12
 
 
13
  intents = discord.Intents.default()
14
  bot = commands.Bot(command_prefix="/", intents=intents)
15
 
 
 
16
  @bot.event
17
  async def on_ready():
18
+ print(f"🩸 CultCore online as {bot.user}")
19
 
20
+ @bot.command()
21
  async def initiate(ctx):
22
+ await ctx.send("⚫ Initiation complete. CultCore awakened.")
23
+
24
+ @bot.command()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  async def status(ctx):
26
+ await ctx.send("🩸 CultCore running inside Hugging Face Space.")
27
+
28
+ def run_bot():
29
+ bot.run(DISCORD_TOKEN)
30
+
31
+ def dummy_ui():
32
+ return "CultCore is alive."
33
 
34
+ # Запускаем Discord-бот в фоне
35
+ threading.Thread(target=run_bot).start()
36
 
37
+ # Пустой Gradio UI (чтобы Space не умер)
38
+ gr.Interface(
39
+ fn=dummy_ui,
40
+ inputs=[],
41
+ outputs="text",
42
+ title="CultCore Core",
43
+ description="Black/Red techno cult AI is running."
44
+ ).launch()