fix completion_text

This commit is contained in:
josc146 2023-05-21 23:25:58 +08:00
parent c40e57aafd
commit 74ceffb32c
2 changed files with 27 additions and 2 deletions

View File

@ -53,5 +53,16 @@ def exit():
parent.kill()
def debug():
model = RWKV(
model="../models/RWKV-4-Raven-7B-v11-Eng49%-Chn49%-Jpn1%-Other1%-20230430-ctx8192.pth",
strategy="cuda fp16",
tokens_path="20B_tokenizer.json",
)
d = model.tokenizer.decode([])
print(d)
if __name__ == "__main__":
uvicorn.run("main:app", port=8000 if len(sys.argv) == 1 else int(sys.argv[1]))
# debug()

View File

@ -42,9 +42,23 @@ async def completions(body: CompletionBody, request: Request):
completion_text = ""
for message in body.messages:
if message.role == "user":
completion_text += "Bob: " + message.content + "\n\n"
completion_text += (
"Bob: "
+ message.content.replace("\\n", "\n")
.replace("\r\n", "\n")
.replace("\n\n", "\n")
.strip()
+ "\n\n"
)
elif message.role == "assistant":
completion_text += "Alice: " + message.content + "\n\n"
completion_text += (
"Alice: "
+ message.content.replace("\\n", "\n")
.replace("\r\n", "\n")
.replace("\n\n", "\n")
.strip()
+ "\n\n"
)
completion_text += "Alice:"
async def eval_rwkv():