Update main.py
Browse files
main.py
CHANGED
@@ -169,8 +169,13 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
|
|
169 |
|
170 |
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
|
171 |
response.raise_for_status()
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
if model == 'ImageGenerationLV45LJp':
|
173 |
-
response_text = await response.text()
|
174 |
url_match = re.search(r'https://storage\.googleapis\.com/[^\s\)]+', response_text)
|
175 |
if url_match:
|
176 |
image_url = url_match.group(0)
|
@@ -271,4 +276,4 @@ async def chat_completions(request: ChatRequest):
|
|
271 |
|
272 |
@app.get("/niansuhai/v1/models")
|
273 |
async def get_models():
|
274 |
-
return {"models": Blackbox.models}
|
|
|
169 |
|
170 |
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
|
171 |
response.raise_for_status()
|
172 |
+
response_text = await response.text()
|
173 |
+
|
174 |
+
# Check if the response is empty
|
175 |
+
if not response_text.strip():
|
176 |
+
raise ModelNotWorkingException(model)
|
177 |
+
|
178 |
if model == 'ImageGenerationLV45LJp':
|
|
|
179 |
url_match = re.search(r'https://storage\.googleapis\.com/[^\s\)]+', response_text)
|
180 |
if url_match:
|
181 |
image_url = url_match.group(0)
|
|
|
276 |
|
277 |
@app.get("/niansuhai/v1/models")
|
278 |
async def get_models():
|
279 |
+
return {"models": Blackbox.models}
|