Skip to content

Commit

Permalink
improve /completions api compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Jul 10, 2023
1 parent 0edec68 commit f9f1d5c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend-python/routes/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Config:


class CompletionBody(ModelConfigBody):
prompt: str
prompt: str or List[str]
model: str = "rwkv"
stream: bool = False
stop: str = None
Expand Down Expand Up @@ -306,9 +306,12 @@ async def completions(body: CompletionBody, request: Request):
if model is None:
raise HTTPException(status.HTTP_400_BAD_REQUEST, "model not loaded")

if body.prompt is None or body.prompt == "":
if body.prompt is None or body.prompt == "" or body.prompt == []:
raise HTTPException(status.HTTP_400_BAD_REQUEST, "prompt not found")

if type(body.prompt) == list:
body.prompt = body.prompt[0] # TODO: support multiple prompts

if body.stream:
return EventSourceResponse(
eval_rwkv(model, request, body, body.prompt, body.stream, body.stop, False)
Expand Down

0 comments on commit f9f1d5c

Please sign in to comment.