From c300fab45eb0233a299bd9bc64636e5df340f987 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Sun, 29 Jun 2025 21:48:58 +0800 Subject: [PATCH] 'commit' --- dsRag/static/ai.html | 41 +++++++++++-------------- dsRag/static/aj.html | 71 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 23 deletions(-) create mode 100644 dsRag/static/aj.html diff --git a/dsRag/static/ai.html b/dsRag/static/ai.html index 4be4956a..7b34f185 100644 --- a/dsRag/static/ai.html +++ b/dsRag/static/ai.html @@ -294,40 +294,35 @@ const selectedDocs = Array.from(checkboxes).map(cb => cb.value); const loader = document.getElementById('loader'); + const answerArea = document.getElementById('answerArea'); + answerArea.innerHTML = ''; loader.style.display = 'block'; fetch('/api/rag', { method: 'POST', headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', }, body: JSON.stringify({ query: question, - tags: selectedDocs // 使用selectedDocs作为tags参数 + tags: selectedDocs }) }) - .then(response => response.json()) - .then(data => { - console.log('Raw response:', data); - return data; - }) // 改回使用json() - .then(data => { - loader.style.display = 'none'; - if (data && data.data) { - document.getElementById('answerArea').innerHTML = marked.parse(data.data); - MathJax.typeset(); - localStorage.setItem('lastMarkdownContent', data.data); - } else { - alert('服务器返回了无效数据'); - } - }) - .catch(error => { - loader.style.display = 'none'; - console.error('Error:', error); - alert('请求失败: ' + error.message); - }); - } + .then(response => response.json()) + .then(data => { + if (data.reply) { + answerArea.innerHTML = marked.parse(data.reply); + MathJax.typeset(); + localStorage.setItem('lastMarkdownContent', data.reply); + } + loader.style.display = 'none'; + }) + .catch(error => { + console.error('Error:', error); + loader.style.display = 'none'; + }); + }ai.html function clearAll() { document.getElementById('questionInput').value = ''; diff --git a/dsRag/static/aj.html b/dsRag/static/aj.html new file mode 100644 index 00000000..d78e5339 --- /dev/null +++ b/dsRag/static/aj.html @@ -0,0 +1,71 @@ + + +
+