From 91e2828a956242abbed3297c45b83d6691d952a8 Mon Sep 17 00:00:00 2001 From: josc146 Date: Fri, 4 Aug 2023 22:22:59 +0800 Subject: [PATCH] allow completions input to be null --- backend-python/routes/completion.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend-python/routes/completion.py b/backend-python/routes/completion.py index 1290053..861d07e 100644 --- a/backend-python/routes/completion.py +++ b/backend-python/routes/completion.py @@ -22,18 +22,18 @@ class Message(BaseModel): class ChatCompletionBody(ModelConfigBody): - messages: List[Message] + messages: Union[List[Message], None] model: str = "rwkv" stream: bool = False - stop: Union[str, List[str]] = [ + stop: Union[str, List[str], None] = [ "\n\nUser", "\n\nQuestion", "\n\nQ", "\n\nHuman", "\n\nBob", ] - user_name: str = None - assistant_name: str = None + user_name: Union[str, None] = None + assistant_name: Union[str, None] = None class Config: schema_extra = { @@ -54,10 +54,10 @@ class ChatCompletionBody(ModelConfigBody): class CompletionBody(ModelConfigBody): - prompt: Union[str, List[str]] + prompt: Union[str, List[str], None] model: str = "rwkv" stream: bool = False - stop: Union[str, List[str]] = None + stop: Union[str, List[str], None] = None class Config: schema_extra = { @@ -87,7 +87,7 @@ async def eval_rwkv( body: ModelConfigBody, prompt: str, stream: bool, - stop: Union[str, List[str]], + stop: Union[str, List[str], None], chat_mode: bool, ): global requests_num @@ -345,7 +345,7 @@ async def completions(body: CompletionBody, request: Request): class EmbeddingsBody(BaseModel): - input: Union[str, List[str], List[List[int]]] + input: Union[str, List[str], List[List[int]], None] model: str = "rwkv" encoding_format: str = None fast_mode: bool = False