Update main.py
Browse files
main.py
CHANGED
@@ -10,8 +10,7 @@ from fastapi import FastAPI, HTTPException
|
|
10 |
from pydantic import BaseModel
|
11 |
from typing import List, Dict, Any, Optional
|
12 |
from datetime import datetime
|
13 |
-
from fastapi import
|
14 |
-
from fastapi.responses import StreamingResponse # Add this import
|
15 |
|
16 |
# Mock implementations for ImageResponse and to_data_uri
|
17 |
class ImageResponse:
|
@@ -171,7 +170,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
|
|
171 |
else:
|
172 |
async for chunk in response.content.iter_any():
|
173 |
if chunk:
|
174 |
-
decoded_chunk = chunk.decode()
|
175 |
decoded_chunk = re.sub(r'\$@\$v=[^$]+\$@\$', '', decoded_chunk)
|
176 |
if decoded_chunk.strip():
|
177 |
yield decoded_chunk
|
|
|
10 |
from pydantic import BaseModel
|
11 |
from typing import List, Dict, Any, Optional
|
12 |
from datetime import datetime
|
13 |
+
from fastapi.responses import StreamingResponse
|
|
|
14 |
|
15 |
# Mock implementations for ImageResponse and to_data_uri
|
16 |
class ImageResponse:
|
|
|
170 |
else:
|
171 |
async for chunk in response.content.iter_any():
|
172 |
if chunk:
|
173 |
+
decoded_chunk = chunk.decode(errors='ignore') # Handle decoding errors
|
174 |
decoded_chunk = re.sub(r'\$@\$v=[^$]+\$@\$', '', decoded_chunk)
|
175 |
if decoded_chunk.strip():
|
176 |
yield decoded_chunk
|