ruff check scripts src tests --fix

Former-commit-id: da5277b6a1cff40d59df8f1835d9514b2a51be34
This commit is contained in:
Tendo33
2024-05-13 09:40:33 +08:00
parent f94b54b776
commit 7589123465
2 changed files with 27 additions and 52 deletions

View File

@@ -56,8 +56,7 @@ def create_app(chat_model: "ChatModel") -> "FastAPI":
async def verify_api_key(auth: Annotated[Optional[HTTPAuthorizationCredentials], Depends(security)]):
if api_key and (auth is None or auth.credentials != api_key):
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid API key.")
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid API key.")
@app.get(
"/v1/models",
@@ -77,12 +76,10 @@ def create_app(chat_model: "ChatModel") -> "FastAPI":
)
async def create_chat_completion(request: ChatCompletionRequest):
if not chat_model.engine.can_generate:
raise HTTPException(
status_code=status.HTTP_405_METHOD_NOT_ALLOWED, detail="Not allowed")
raise HTTPException(status_code=status.HTTP_405_METHOD_NOT_ALLOWED, detail="Not allowed")
if request.stream:
generate = create_stream_chat_completion_response(
request, chat_model)
generate = create_stream_chat_completion_response(request, chat_model)
return EventSourceResponse(generate, media_type="text/event-stream")
else:
return await create_chat_completion_response(request, chat_model)
@@ -95,8 +92,7 @@ def create_app(chat_model: "ChatModel") -> "FastAPI":
)
async def create_score_evaluation(request: ScoreEvaluationRequest):
if chat_model.engine.can_generate:
raise HTTPException(
status_code=status.HTTP_405_METHOD_NOT_ALLOWED, detail="Not allowed")
raise HTTPException(status_code=status.HTTP_405_METHOD_NOT_ALLOWED, detail="Not allowed")
return await create_score_evaluation_response(request, chat_model)