From 0d5e5a9f8e398043bb6b68f79a984491890c2ec9 Mon Sep 17 00:00:00 2001 From: Archeb Date: Wed, 24 Apr 2024 11:07:56 +0800 Subject: [PATCH] Fix 414 URI Too Large --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c5110d9..5c831b1 100644 --- a/index.js +++ b/index.js @@ -100,7 +100,7 @@ app.post("/v1/messages", (req, res) => { // 试算用户消息长度 - if(encodeURIComponent(JSON.stringify(userMessage)).length > 30000) { + if(encodeURIComponent(JSON.stringify(userMessage)).length + encodeURIComponent(userQuery).length > 32000) { //太长了,需要上传 // user message to plaintext @@ -110,7 +110,7 @@ app.post("/v1/messages", (req, res) => { }) .join("\n\n"); - userQuery = userMessage[userMessage.length - 1].question; + userQuery = "Please view the document and reply."; userMessage = []; // GET https://you.com/api/get_nonce to get nonce