improve /completions
api compatibility
This commit is contained in:
parent
0edec68376
commit
f9f1d5c9fc
@ -44,7 +44,7 @@ class ChatCompletionBody(ModelConfigBody):
|
|||||||
|
|
||||||
|
|
||||||
class CompletionBody(ModelConfigBody):
|
class CompletionBody(ModelConfigBody):
|
||||||
prompt: str
|
prompt: str or List[str]
|
||||||
model: str = "rwkv"
|
model: str = "rwkv"
|
||||||
stream: bool = False
|
stream: bool = False
|
||||||
stop: str = None
|
stop: str = None
|
||||||
@ -306,9 +306,12 @@ async def completions(body: CompletionBody, request: Request):
|
|||||||
if model is None:
|
if model is None:
|
||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "model not loaded")
|
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")
|
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:
|
if body.stream:
|
||||||
return EventSourceResponse(
|
return EventSourceResponse(
|
||||||
eval_rwkv(model, request, body, body.prompt, body.stream, body.stop, False)
|
eval_rwkv(model, request, body, body.prompt, body.stream, body.stop, False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user