Former-commit-id: cca004da28aaaa0788eaea62b83d3402b38a3011
This commit is contained in:
hiyouga
2024-01-21 19:15:27 +08:00
parent 96531a0ef8
commit 3fda60fca0
3 changed files with 48 additions and 2 deletions

View File

@@ -85,7 +85,7 @@ def create_app(chat_model: "ChatModel") -> "FastAPI":
if not chat_model.can_generate:
raise HTTPException(status_code=status.HTTP_405_METHOD_NOT_ALLOWED, detail="Not allowed")
if len(request.messages) == 0 or request.messages[-1].role != Role.USER:
if len(request.messages) == 0 or request.messages[-1].role not in [Role.USER, Role.TOOL]:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid length")
messages = [dictify(message) for message in request.messages]