Spaces:
Running
Running
Update fluxai.py
Browse files
fluxai.py
CHANGED
@@ -17,10 +17,11 @@ import uuid
|
|
17 |
from RyuzakiLib import GeminiLatest
|
18 |
|
19 |
class FluxAI(BaseModel):
|
20 |
-
user_id: int
|
21 |
api_key: str
|
22 |
args: str
|
23 |
auto_enhancer: bool = False
|
|
|
24 |
|
25 |
class MistralAI(BaseModel):
|
26 |
args: str
|
@@ -46,6 +47,16 @@ async def schellwithflux(args):
|
|
46 |
return None
|
47 |
return response.content
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
async def mistralai_post_message(message_str):
|
50 |
client = InferenceClient(
|
51 |
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
@@ -121,7 +132,10 @@ async def fluxai_image(payload: FluxAI):
|
|
121 |
USERS_API_KEYS = get_all_api_keys()
|
122 |
if payload.api_key in USERS_API_KEYS:
|
123 |
try:
|
124 |
-
|
|
|
|
|
|
|
125 |
if image_bytes is None:
|
126 |
return SuccessResponse(
|
127 |
status="False",
|
|
|
17 |
from RyuzakiLib import GeminiLatest
|
18 |
|
19 |
class FluxAI(BaseModel):
|
20 |
+
user_id: int = 1191668125
|
21 |
api_key: str
|
22 |
args: str
|
23 |
auto_enhancer: bool = False
|
24 |
+
is_flux_dev: bool = False
|
25 |
|
26 |
class MistralAI(BaseModel):
|
27 |
args: str
|
|
|
47 |
return None
|
48 |
return response.content
|
49 |
|
50 |
+
async def devwithflux(args):
|
51 |
+
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
52 |
+
headers = {"Authorization": f"Bearer {HUGGING_TOKEN}"}
|
53 |
+
payload = {"inputs": args}
|
54 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
55 |
+
if response.status_code != 200:
|
56 |
+
print(f"Error status {response.status_code}")
|
57 |
+
return None
|
58 |
+
return response.content
|
59 |
+
|
60 |
async def mistralai_post_message(message_str):
|
61 |
client = InferenceClient(
|
62 |
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
|
|
132 |
USERS_API_KEYS = get_all_api_keys()
|
133 |
if payload.api_key in USERS_API_KEYS:
|
134 |
try:
|
135 |
+
if payload.is_flux_dev:
|
136 |
+
image_bytes = await devwithflux(payload.args)
|
137 |
+
else:
|
138 |
+
image_bytes = await schellwithflux(payload.args)
|
139 |
if image_bytes is None:
|
140 |
return SuccessResponse(
|
141 |
status="False",
|