Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,6 @@ import aiohttp # Use aiohttp for asynchronous HTTP requests
|
|
7 |
import gradio as gr # Import Gradio
|
8 |
|
9 |
# --- Environment Variables & Setup ---
|
10 |
-
global GLIF_API_TOKEN
|
11 |
-
global glif_token_id
|
12 |
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
13 |
GLIF_API_TOKEN = os.getenv("GLIF_API_TOKEN")
|
14 |
GLIF_API_URL = "https://simple-api.glif.app"
|
@@ -25,6 +23,8 @@ tree = app_commands.CommandTree(client)
|
|
25 |
|
26 |
|
27 |
async def generate_image_async(prompt, aspect_ratio):
|
|
|
|
|
28 |
payload = {
|
29 |
"id": "cm3ugmzv2002gnckiosrwk6xi",
|
30 |
"inputs": [prompt, aspect_ratio],
|
@@ -41,9 +41,7 @@ async def generate_image_async(prompt, aspect_ratio):
|
|
41 |
if "error" in response_data:
|
42 |
if 'error 429' in response_data['error']:
|
43 |
if glif_tokens_tried<no_of_accounts:
|
44 |
-
global glif_token_id
|
45 |
glif_token_id = (glif_token_id+1)%no_of_accounts
|
46 |
-
global GLIF_API_TOKEN
|
47 |
GLIF_API_TOKEN = os.getenv(f"GLIF_API_TOKEN{glif_token_id}")
|
48 |
response_data = await generate_image_async(prompt, aspect_ratio)
|
49 |
glif_tokens_tried = 0
|
|
|
7 |
import gradio as gr # Import Gradio
|
8 |
|
9 |
# --- Environment Variables & Setup ---
|
|
|
|
|
10 |
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN")
|
11 |
GLIF_API_TOKEN = os.getenv("GLIF_API_TOKEN")
|
12 |
GLIF_API_URL = "https://simple-api.glif.app"
|
|
|
23 |
|
24 |
|
25 |
async def generate_image_async(prompt, aspect_ratio):
|
26 |
+
global glif_token_id
|
27 |
+
global GLIF_API_TOKEN
|
28 |
payload = {
|
29 |
"id": "cm3ugmzv2002gnckiosrwk6xi",
|
30 |
"inputs": [prompt, aspect_ratio],
|
|
|
41 |
if "error" in response_data:
|
42 |
if 'error 429' in response_data['error']:
|
43 |
if glif_tokens_tried<no_of_accounts:
|
|
|
44 |
glif_token_id = (glif_token_id+1)%no_of_accounts
|
|
|
45 |
GLIF_API_TOKEN = os.getenv(f"GLIF_API_TOKEN{glif_token_id}")
|
46 |
response_data = await generate_image_async(prompt, aspect_ratio)
|
47 |
glif_tokens_tried = 0
|