improve default ChatCompletion stop
This commit is contained in:
parent
719090cc8c
commit
3ef22239eb
@ -25,7 +25,13 @@ class ChatCompletionBody(ModelConfigBody):
|
|||||||
messages: List[Message]
|
messages: List[Message]
|
||||||
model: str = "rwkv"
|
model: str = "rwkv"
|
||||||
stream: bool = False
|
stream: bool = False
|
||||||
stop: Union[str, List[str]] = None
|
stop: Union[str, List[str]] = [
|
||||||
|
"\n\nUser",
|
||||||
|
"\n\nQuestion",
|
||||||
|
"\n\nQ",
|
||||||
|
"\n\nHuman",
|
||||||
|
"\n\nBob",
|
||||||
|
]
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
schema_extra = {
|
schema_extra = {
|
||||||
@ -77,7 +83,7 @@ async def eval_rwkv(
|
|||||||
body: ModelConfigBody,
|
body: ModelConfigBody,
|
||||||
prompt: str,
|
prompt: str,
|
||||||
stream: bool,
|
stream: bool,
|
||||||
stop: str,
|
stop: Union[str, List[str]],
|
||||||
chat_mode: bool,
|
chat_mode: bool,
|
||||||
):
|
):
|
||||||
global requests_num
|
global requests_num
|
||||||
@ -285,15 +291,16 @@ The following is a coherent verbose detailed conversation between a girl named {
|
|||||||
)
|
)
|
||||||
completion_text += f"{bot}{interface}"
|
completion_text += f"{bot}{interface}"
|
||||||
|
|
||||||
stop = f"\n\n{user}" if body.stop is None else body.stop
|
|
||||||
if body.stream:
|
if body.stream:
|
||||||
return EventSourceResponse(
|
return EventSourceResponse(
|
||||||
eval_rwkv(model, request, body, completion_text, body.stream, stop, True)
|
eval_rwkv(
|
||||||
|
model, request, body, completion_text, body.stream, body.stop, True
|
||||||
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
return await eval_rwkv(
|
return await eval_rwkv(
|
||||||
model, request, body, completion_text, body.stream, stop, True
|
model, request, body, completion_text, body.stream, body.stop, True
|
||||||
).__anext__()
|
).__anext__()
|
||||||
except StopAsyncIteration:
|
except StopAsyncIteration:
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user