add exception

main
Junyang Lin 1 year ago committed by GitHub
parent f91e7b3c87
commit c84d2f685a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -113,6 +113,10 @@ async def create_chat_completion(request: ChatCompletionRequest):
for i in range(0, len(prev_messages), 2): for i in range(0, len(prev_messages), 2):
if prev_messages[i].role == "user" and prev_messages[i+1].role == "assistant": if prev_messages[i].role == "user" and prev_messages[i+1].role == "assistant":
history.append([prev_messages[i].content, prev_messages[i+1].content]) history.append([prev_messages[i].content, prev_messages[i+1].content])
else:
raise HTTPException(status_code=400, detail="Invalid request.")
else:
raise HTTPException(status_code=400, detail="Invalid request.")
if request.stream: if request.stream:
generate = predict(query, history, request.model) generate = predict(query, history, request.model)

Loading…
Cancel
Save