Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -198,11 +198,7 @@ server_status = False
|
|
| 198 |
@app.post("api/v1/chat/completions")
|
| 199 |
async def get_completion(payload: Payload, request: Request):
|
| 200 |
# Check server status
|
| 201 |
-
|
| 202 |
-
return JSONResponse(
|
| 203 |
-
status_code=503,
|
| 204 |
-
content={"message": "Server is under maintenance. Please try again later."}
|
| 205 |
-
)
|
| 206 |
|
| 207 |
model_to_use = payload.model if payload.model else "gpt-4o-mini"
|
| 208 |
|
|
@@ -225,8 +221,13 @@ async def get_completion(payload: Payload, request: Request):
|
|
| 225 |
# Current time and IP logging
|
| 226 |
current_time = (datetime.datetime.utcnow() + datetime.timedelta(hours=5, minutes=30)).strftime("%Y-%m-%d %I:%M:%S %p")
|
| 227 |
aaip = request.client.host
|
| 228 |
-
print(f"Time: {current_time}, {aaip} , {model_to_use}")
|
| 229 |
print(payload_dict)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
scraper = cloudscraper.create_scraper()
|
| 231 |
async def stream_generator(payload_dict):
|
| 232 |
|
|
|
|
| 198 |
@app.post("api/v1/chat/completions")
|
| 199 |
async def get_completion(payload: Payload, request: Request):
|
| 200 |
# Check server status
|
| 201 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
model_to_use = payload.model if payload.model else "gpt-4o-mini"
|
| 204 |
|
|
|
|
| 221 |
# Current time and IP logging
|
| 222 |
current_time = (datetime.datetime.utcnow() + datetime.timedelta(hours=5, minutes=30)).strftime("%Y-%m-%d %I:%M:%S %p")
|
| 223 |
aaip = request.client.host
|
| 224 |
+
print(f"Time: {current_time}, {aaip} , {model_to_use}, server status :- {server_status}")
|
| 225 |
print(payload_dict)
|
| 226 |
+
if not server_status:
|
| 227 |
+
return JSONResponse(
|
| 228 |
+
status_code=503,
|
| 229 |
+
content={"message": "Server is under maintenance. Please try again later."}
|
| 230 |
+
)
|
| 231 |
scraper = cloudscraper.create_scraper()
|
| 232 |
async def stream_generator(payload_dict):
|
| 233 |
|