Niansuh commited on
Commit
006b988
·
verified ·
1 Parent(s): 1815722

Update api/routes.py

Browse files
Files changed (1) hide show
  1. api/routes.py +9 -7
api/routes.py CHANGED
@@ -36,10 +36,12 @@ async def chat_completions(
36
  logger.info("Entering chat_completions route")
37
  logger.info(f"Processing chat completion request for model: {request.model}")
38
 
39
- if request.model not in [model["id"] for model in ALLOWED_MODELS]:
 
 
40
  raise HTTPException(
41
  status_code=400,
42
- detail=f"Model {request.model} is not allowed. Allowed models are: {', '.join(model['id'] for model in ALLOWED_MODELS)}",
43
  )
44
 
45
  if request.stream:
@@ -49,11 +51,11 @@ async def chat_completions(
49
  logger.info("Non-streaming response")
50
  return await process_non_streaming_response(request)
51
 
52
- @router.route('/')
53
- @router.route('/healthz')
54
- @router.route('/ready')
55
- @router.route('/alive')
56
- @router.route('/status')
57
  @router.get("/health")
 
 
 
 
 
58
  def health_check(request: Request):
59
  return Response(content=json.dumps({"status": "ok"}), media_type="application/json")
 
36
  logger.info("Entering chat_completions route")
37
  logger.info(f"Processing chat completion request for model: {request.model}")
38
 
39
+ # Validate if the requested model is allowed
40
+ allowed_model_ids = [model["id"] for model in ALLOWED_MODELS]
41
+ if request.model not in allowed_model_ids:
42
  raise HTTPException(
43
  status_code=400,
44
+ detail=f"Model {request.model} is not allowed. Allowed models are: {', '.join(allowed_model_ids)}",
45
  )
46
 
47
  if request.stream:
 
51
  logger.info("Non-streaming response")
52
  return await process_non_streaming_response(request)
53
 
 
 
 
 
 
54
  @router.get("/health")
55
+ @router.get("/")
56
+ @router.get("/healthz")
57
+ @router.get("/ready")
58
+ @router.get("/alive")
59
+ @router.get("/status")
60
  def health_check(request: Request):
61
  return Response(content=json.dumps({"status": "ok"}), media_type="application/json")