From 77670268424274b3789f4004dca1f7cb21b3ff1b Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Mon, 20 Mar 2023 19:50:59 +0800 Subject: [PATCH] update --- api/chat_main_handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/chat_main_handler.go b/api/chat_main_handler.go index a4642d9a..4dbdf408 100644 --- a/api/chat_main_handler.go +++ b/api/chat_main_handler.go @@ -150,10 +150,14 @@ func (h *ChatHandler) OpenAIChatCompletionAPIWithStreamHandler(w http.ResponseWr http.Error(w, "Error: '"+err.Error()+"'", http.StatusBadRequest) return } + lastN := chat_session.MaxLength + if chat_session.MaxLength == 0 { + lastN = 10 + } msgs, err := h.chatService.q.GetLastNChatMessages(ctx, sqlc_queries.GetLastNChatMessagesParams{ Uuid: chatUuid, - Limit: chat_session.MaxLength, + Limit: lastN, }) if err != nil { http.Error(w, "Error: '"+err.Error()+"'", http.StatusBadRequest)