From c70bda98c9f0ed9f09c105e2ea7703e30b51e1fb Mon Sep 17 00:00:00 2001 From: shaoyongjun Date: Wed, 22 May 2024 17:45:49 +0800 Subject: [PATCH] to:sync --- static/ai-chat1.html | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/static/ai-chat1.html b/static/ai-chat1.html index f9e5e75..97829ef 100644 --- a/static/ai-chat1.html +++ b/static/ai-chat1.html @@ -189,29 +189,29 @@ slideBottom(); // messagesList.push({role: "user", content: msg}); - const body = JSON.stringify({model: "google/gemma-7b-it:free", messages: [{role: "user", content: msg}]}); + const body = JSON.stringify({ "prompt": msg}); // alert(body) $.ajax({ method: 'POST', - url: 'https://openrouter.ai/api/v1/chat/completions', + url: '/v1/ai/completionsTest', headers: { 'Content-Type': 'application/json', - 'Authorization': 'Bearer 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' }, data: body, success: function (res) { - let res1=res?.choices[0]?.message?.content; - res1 = DOMPurify.sanitize(marked.parse(res1)); - addAIMessage(res1); + // let res1=res?.choices[0]?.message?.content; + // res1 = DOMPurify.sanitize(marked.parse(res1)); + // addAIMessage(res1); - // if (res.code === 200) { - // let answer = res.answer; - // answer = marked.parse(answer); - // addAIMessage(answer); - // messageHistory = res.history; - // } else { - // addAIMessage("服务接口调用错误。"); - // } + if (res.code === 0) { + let answer = res.data; + // answer = marked.parse(answer); + answer = DOMPurify.sanitize(marked.parse(answer)); + addAIMessage(answer); + // messageHistory = res.history; + } else { + addAIMessage("服务接口调用错误。"); + } }, error: function (e) { addAIMessage("服务接口调用异常。");