|
25 | 25 | logger = logging.getLogger("DeepSeekProxy") |
26 | 26 |
|
27 | 27 | SILICON_FLOW_BASE_URL = "https://api.siliconflow.cn/v1" |
28 | | -SILICON_FLOW_API_KEY = os.getenv("SILICON_FLOW_API_KEY", "sk-your-siliconflow-key-here") |
| 28 | +SILICON_FLOW_API_KEY = os.getenv("SILICON_FLOW_API_KEY") |
29 | 29 |
|
30 | 30 | MODEL_MAPPING = { |
31 | 31 | "deepseek-v3": "deepseek-ai/DeepSeek-V3", |
@@ -116,7 +116,7 @@ class GenerationRequest(BaseModel): |
116 | 116 | class DeepSeekProxy: |
117 | 117 | def __init__(self): |
118 | 118 | self.client = OpenAI( |
119 | | - api_key=SILICON_FLOW_API_KEY, |
| 119 | + api_key=SILICON_FLOW_API_KEY if SILICON_FLOW_API_KEY else None, |
120 | 120 | base_url=SILICON_FLOW_BASE_URL |
121 | 121 | ) |
122 | 122 |
|
@@ -344,6 +344,22 @@ async def request_tracker(request: Request, call_next): |
344 | 344 | duration = (time.time() - start_time) * 1000 |
345 | 345 | logger.info(f"{request.method} {request.url.path} - {duration:.2f}ms") |
346 | 346 |
|
| 347 | + # --- [New Endpoint] Health Check --- |
| 348 | + @app.get("/health_check") |
| 349 | + async def health_check(): |
| 350 | + """ |
| 351 | + Liveness probe verifying server status and current mode. |
| 352 | + """ |
| 353 | + return JSONResponse( |
| 354 | + status_code=200, |
| 355 | + content={ |
| 356 | + "status": "healthy", |
| 357 | + "service": "DeepSeek-DashScope-Proxy", |
| 358 | + "timestamp": time.time(), |
| 359 | + "mode": "mock" if SERVER_STATE.is_mock_mode else "production" |
| 360 | + } |
| 361 | + ) |
| 362 | + |
347 | 363 | @app.post("/api/v1/services/aigc/text-generation/generation") |
348 | 364 | async def generation(request: Request, body: GenerationRequest = None): |
349 | 365 | request_id = request.headers.get("x-request-id", str(uuid.uuid4())) |
|
0 commit comments