API: Fix exceptions and defaults
Stop conditions was None, causing model to error out when trying to add the EOS token to a None value. Authentication failed when Bearer contained an empty string. To fix this, add a condition which checks array length. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
4669e49ff0
commit
d627d14385
2 changed files with 9 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ class CommonCompletionRequest(BaseModel):
|
|||
# Generation info
|
||||
seed: Optional[int] = -1
|
||||
stream: Optional[bool] = False
|
||||
stop: Optional[Union[str, List[str]]] = None
|
||||
stop: Optional[Union[str, List[str]]] = []
|
||||
|
||||
# Default to 150 as 16 makes no sense as a default
|
||||
max_tokens: Optional[int] = 150
|
||||
|
|
|
|||
10
auth.py
10
auth.py
|
|
@ -45,7 +45,10 @@ def check_api_key(x_api_key: str = Header(None), authorization: str = Header(Non
|
|||
raise HTTPException(401, "Invalid API key")
|
||||
elif authorization:
|
||||
split_key = authorization.split(" ")
|
||||
if split_key[0].lower() == "bearer" and split_key[1] in auth_keys.api_key:
|
||||
|
||||
if len(split_key) < 2:
|
||||
raise HTTPException(401, "Invalid API key")
|
||||
elif split_key[0].lower() == "bearer" and split_key[1] in auth_keys.api_key:
|
||||
return authorization
|
||||
else:
|
||||
raise HTTPException(401, "Invalid API key")
|
||||
|
|
@ -60,7 +63,10 @@ def check_admin_key(x_admin_key: str = Header(None), authorization: str = Header
|
|||
raise HTTPException(401, "Invalid admin key")
|
||||
elif authorization:
|
||||
split_key = authorization.split(" ")
|
||||
if split_key[0].lower() == "bearer" and split_key[1] in auth_keys.admin_key:
|
||||
|
||||
if len(split_key) < 2:
|
||||
raise HTTPException(401, "Invalid admin key")
|
||||
elif split_key[0].lower() == "bearer" and split_key[1] in auth_keys.admin_key:
|
||||
return authorization
|
||||
else:
|
||||
raise HTTPException(401, "Invalid admin key")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue