wop commited on
Commit
bfd36b9
1 Parent(s): c749a32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -18,6 +18,12 @@ event = Event()
18
 
19
  DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
20
  HF_TOKEN = os.getenv("HF_TOKEN")
 
 
 
 
 
 
21
 
22
  def ask(input_text):
23
  api_url = "https://somerandomapifor-disorc-cause-i-need-it.onrender.com/qa"
@@ -67,10 +73,26 @@ async def ai(ctx, *, input_text: str):
67
  # Reply with the embed
68
  await ctx.send(result)
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  @bot.command()
72
  async def verse(ctx):
73
- """Returns a random Bible verse."""
74
  # Fetch a random Bible verse
75
  bible_api_url = "https://labs.bible.org/api/?passage=random&type=json"
76
  response = requests.get(bible_api_url)
 
18
 
19
  DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
20
  HF_TOKEN = os.getenv("HF_TOKEN")
21
+ API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
22
+ headers = {"Authorization": "Bearer " + HF_TOKEN}
23
+
24
+ def query(payload):
25
+ response = requests.post(API_URL, headers=headers, json=payload)
26
+ return response.content
27
 
28
  def ask(input_text):
29
  api_url = "https://somerandomapifor-disorc-cause-i-need-it.onrender.com/qa"
 
73
  # Reply with the embed
74
  await ctx.send(result)
75
 
76
+ @bot.command()
77
+ async def img(ctx, *, prompt: str):
78
+ """Create an image with description using AI."""
79
+ # Your payload for the image generation (modify as needed)
80
+ payload = {
81
+ "prompt": prompt,
82
+ "num_return_sequences": 1
83
+ }
84
+
85
+ # Query the API to generate the image
86
+ image_data = query(payload)
87
+
88
+ # Send the image as a file
89
+ await ctx.send(file=discord.File(image_data, filename="generated_image.png"))
90
+
91
+
92
 
93
  @bot.command()
94
  async def verse(ctx):
95
+ """Get a random Bible verse."""
96
  # Fetch a random Bible verse
97
  bible_api_url = "https://labs.bible.org/api/?passage=random&type=json"
98
  response = requests.get(bible_api_url)