Spaces:
Running
Running
Update gen.py
Browse files
gen.py
CHANGED
|
@@ -42,7 +42,7 @@ PKEY3 = os.getenv("POLLINATIONS3_KEY", "")
|
|
| 42 |
AIRFORCE_KEY = os.getenv("AIRFORCE")
|
| 43 |
AIRFORCE_VIDEO_MODEL = "grok-imagine-video"
|
| 44 |
AIRFORCE_API_URL = "https://api.airforce/v1/images/generations"
|
| 45 |
-
|
| 46 |
valid_ratios = {"3:2", "2:3", "1:1", "", None}
|
| 47 |
ratios = {"3:2", "2:3", "1:1"}
|
| 48 |
valid_modes = {"normal", "fun", "", None}
|
|
@@ -123,7 +123,7 @@ async def generate_image(
|
|
| 123 |
|
| 124 |
prompt = normalize_prompt_value(prompt, "prompt")
|
| 125 |
enforce_prompt_size(prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Image prompt")
|
| 126 |
-
if request.headers.get("x-payg-internal") !=
|
| 127 |
await check_image_rate_limit(request, authorization, x_client_id)
|
| 128 |
|
| 129 |
chosen_model = "zimage"
|
|
@@ -191,7 +191,7 @@ async def gensfx(
|
|
| 191 |
|
| 192 |
prompt = normalize_prompt_value(prompt, "prompt")
|
| 193 |
enforce_prompt_size(prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Audio prompt")
|
| 194 |
-
if request.headers.get("x-payg-internal") !=
|
| 195 |
await check_audio_rate_limit(request, authorization, x_client_id)
|
| 196 |
|
| 197 |
url = f"https://gen.pollinations.ai/audio/{prompt}?model=acestep&key={PKEY}"
|
|
@@ -225,7 +225,7 @@ async def gentts(
|
|
| 225 |
|
| 226 |
prompt = normalize_prompt_value(prompt, "prompt")
|
| 227 |
enforce_prompt_size(prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Audio prompt")
|
| 228 |
-
if request.headers.get("x-payg-internal") !=
|
| 229 |
await check_audio_rate_limit(request, authorization, x_client_id)
|
| 230 |
|
| 231 |
url = f"https://gen.pollinations.ai/audio/{prompt}?model=universal-3-pro&key={PKEY3}"
|
|
@@ -316,7 +316,7 @@ async def genvideo(request: Request, prompt: str = None, authorization: str = He
|
|
| 316 |
enforce_prompt_size(
|
| 317 |
prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Video prompt"
|
| 318 |
)
|
| 319 |
-
if request.headers.get("x-payg-internal") !=
|
| 320 |
await check_video_rate_limit(request, authorization, x_client_id)
|
| 321 |
|
| 322 |
RATIO_MAP = {
|
|
@@ -469,7 +469,7 @@ async def genvideo_airforce(
|
|
| 469 |
enforce_prompt_size(
|
| 470 |
prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Video prompt"
|
| 471 |
)
|
| 472 |
-
if request.headers.get("x-payg-internal") !=
|
| 473 |
await check_video_rate_limit(request, authorization, x_client_id)
|
| 474 |
|
| 475 |
payload = {
|
|
@@ -634,7 +634,7 @@ async def generate_text(
|
|
| 634 |
provider = "cerebras"
|
| 635 |
chosen_model = "gpt-oss-120b"
|
| 636 |
|
| 637 |
-
if request.headers.get("x-payg-internal") !=
|
| 638 |
await check_chat_rate_limit(request, authorization, x_client_id)
|
| 639 |
|
| 640 |
body["model"] = chosen_model
|
|
|
|
| 42 |
AIRFORCE_KEY = os.getenv("AIRFORCE")
|
| 43 |
AIRFORCE_VIDEO_MODEL = "grok-imagine-video"
|
| 44 |
AIRFORCE_API_URL = "https://api.airforce/v1/images/generations"
|
| 45 |
+
WEBSOCKET_KEY = os.getenv("WEBSOCKET_KEY", "")
|
| 46 |
valid_ratios = {"3:2", "2:3", "1:1", "", None}
|
| 47 |
ratios = {"3:2", "2:3", "1:1"}
|
| 48 |
valid_modes = {"normal", "fun", "", None}
|
|
|
|
| 123 |
|
| 124 |
prompt = normalize_prompt_value(prompt, "prompt")
|
| 125 |
enforce_prompt_size(prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Image prompt")
|
| 126 |
+
if request.headers.get("x-payg-internal") != WEBSOCKET_KEY:
|
| 127 |
await check_image_rate_limit(request, authorization, x_client_id)
|
| 128 |
|
| 129 |
chosen_model = "zimage"
|
|
|
|
| 191 |
|
| 192 |
prompt = normalize_prompt_value(prompt, "prompt")
|
| 193 |
enforce_prompt_size(prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Audio prompt")
|
| 194 |
+
if request.headers.get("x-payg-internal") != WEBSOCKET_KEY:
|
| 195 |
await check_audio_rate_limit(request, authorization, x_client_id)
|
| 196 |
|
| 197 |
url = f"https://gen.pollinations.ai/audio/{prompt}?model=acestep&key={PKEY}"
|
|
|
|
| 225 |
|
| 226 |
prompt = normalize_prompt_value(prompt, "prompt")
|
| 227 |
enforce_prompt_size(prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Audio prompt")
|
| 228 |
+
if request.headers.get("x-payg-internal") != WEBSOCKET_KEY:
|
| 229 |
await check_audio_rate_limit(request, authorization, x_client_id)
|
| 230 |
|
| 231 |
url = f"https://gen.pollinations.ai/audio/{prompt}?model=universal-3-pro&key={PKEY3}"
|
|
|
|
| 316 |
enforce_prompt_size(
|
| 317 |
prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Video prompt"
|
| 318 |
)
|
| 319 |
+
if request.headers.get("x-payg-internal") != WEBSOCKET_KEY:
|
| 320 |
await check_video_rate_limit(request, authorization, x_client_id)
|
| 321 |
|
| 322 |
RATIO_MAP = {
|
|
|
|
| 469 |
enforce_prompt_size(
|
| 470 |
prompt, MAX_MEDIA_PROMPT_CHARS, MAX_MEDIA_PROMPT_BYTES, "Video prompt"
|
| 471 |
)
|
| 472 |
+
if request.headers.get("x-payg-internal") != WEBSOCKET_KEY:
|
| 473 |
await check_video_rate_limit(request, authorization, x_client_id)
|
| 474 |
|
| 475 |
payload = {
|
|
|
|
| 634 |
provider = "cerebras"
|
| 635 |
chosen_model = "gpt-oss-120b"
|
| 636 |
|
| 637 |
+
if request.headers.get("x-payg-internal") != WEBSOCKET_KEY:
|
| 638 |
await check_chat_rate_limit(request, authorization, x_client_id)
|
| 639 |
|
| 640 |
body["model"] = chosen_model
|