From 34dd9d926c13c443a125ad3638e38e6fc9219393 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Mon, 30 Jun 2025 07:42:21 +0800 Subject: [PATCH] 'commit' --- .../Config/__pycache__/Config.cpython-310.pyc | Bin 705 -> 705 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 137 -> 137 bytes ...lasticsearchConnectionPool.cpython-310.pyc | Bin 2754 -> 2754 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 144 -> 144 bytes .../__pycache__/EsSearchUtil.cpython-310.pyc | Bin 3967 -> 3967 bytes .../__pycache__/SearchUtil.cpython-310.pyc | Bin 3066 -> 3066 bytes .../Util/__pycache__/__init__.cpython-310.pyc | Bin 135 -> 135 bytes dsRag/static/ai.html | 175 +++++++++++------- dsRag/static/aj.html | 71 ------- 9 files changed, 104 insertions(+), 142 deletions(-) delete mode 100644 dsRag/static/aj.html diff --git a/dsRag/Config/__pycache__/Config.cpython-310.pyc b/dsRag/Config/__pycache__/Config.cpython-310.pyc index aba3f494c522d3624114892add3f2a0a8a6f05f2..e244bc2194d8482da9f8ca036f66f484acc8b30f 100644 GIT binary patch delta 93 zcmX@edXSYXpO=@50SL~Wn#lEBI*KbPu{bk1KC!eUBZ{XiwJ0;KGCn!AsH8Y*G7sZ- v=_pRu;CN?$KQ~YJTfDyhF0MZDjsc$W-ma0iCd)Bdv#|k9Dq@=)&y)lJf-M~A delta 93 zcmX@edXSYXpO=@50SF{KCvrWPzQvW4Se%(0pIBOwaf_!cwJ0;KGCn!AsHFJTWFE%v v(ziHWgX5k3{oFj=qj-J&U0i+Q9Rob$y}2H1=jG*M0D=QgCvw#T03*BvaR2}S delta 18 XcmeBV>}2H1=jG*M0D|>K6S?XEAe#fN diff --git a/dsRag/ElasticSearch/Utils/__pycache__/ElasticsearchConnectionPool.cpython-310.pyc b/dsRag/ElasticSearch/Utils/__pycache__/ElasticsearchConnectionPool.cpython-310.pyc index 6b0788000f2d14c31b78591e5124b342f7c593e7..2c77d6cb0573b0c90091426b9fc84ff0e3f8d74b 100644 GIT binary patch delta 19 ZcmX>kdPtNjpO=@50SKZDH*)RZ0st-T1XKV3 delta 19 ZcmX>kdPtNjpO=@50SI<@Z{*s+1pqLk1k3;c diff --git a/dsRag/ElasticSearch/__pycache__/__init__.cpython-310.pyc b/dsRag/ElasticSearch/__pycache__/__init__.cpython-310.pyc index f7c5e0e6a622fc3bc50e548acf6d6728aa53a406..94ae6ce2baf4d4f283db992edbc385bb28d4e8c7 100644 GIT binary patch delta 18 YcmbQhIDwHXpO=@50SKaaCUUg_03S~SM*si- delta 18 YcmbQhIDwHXpO=@50SI<@PvmL?03sm+ @@ -231,32 +259,32 @@ @@ -283,12 +311,8 @@ const selectedDocs = Array.from(checkboxes).map(cb => cb.value); const answerArea = document.getElementById('answerArea'); - answerArea.innerHTML = ''; - - const data = { - query: question, - tags: selectedDocs - }; + // 添加加载动画 + answerArea.innerHTML = '
思考中...
'; fetch('/api/rag', { method: 'POST', @@ -296,52 +320,60 @@ 'Content-Type': 'application/json', 'Accept': 'text/event-stream' }, - body: JSON.stringify(data) + body: JSON.stringify({ + query: question, + tags: selectedDocs + }) }) - .then(response => { - const reader = response.body.getReader(); - const decoder = new TextDecoder(); - let buffer = ''; - let accumulatedContent = ''; - - function processChunk() { - return reader.read().then(({done, value}) => { - if (done) return; - - buffer += decoder.decode(value, {stream: true}); - const lines = buffer.split('\n'); - buffer = lines.pop(); - - for (const line of lines) { - if (line.includes('data:')) { - const jsonStr = line.replace(/^data:\s*/, '').replace(/^data:\s*/, '').trim(); - if (jsonStr) { - try { - const data = JSON.parse(jsonStr); - if (data.reply) { - accumulatedContent += data.reply; - answerArea.innerHTML = marked.parse(accumulatedContent); - MathJax.typesetPromise(); + .then(response => { + const reader = response.body.getReader(); + const decoder = new TextDecoder(); + let buffer = ''; + let accumulatedContent = ''; + + function processChunk() { + return reader.read().then(({done, value}) => { + if (done) return; + + buffer += decoder.decode(value, {stream: true}); + const lines = buffer.split('\n'); + buffer = lines.pop(); + + for (const line of lines) { + if (line.includes('data:')) { + const jsonStr = line.replace(/^data:\s*/, '').replace(/^data:\s*/, '').trim(); + if (jsonStr) { + try { + const data = JSON.parse(jsonStr); + if (data.reply) { + accumulatedContent += data.reply; + answerArea.innerHTML = marked.parse(accumulatedContent); + MathJax.typesetPromise(); + } + } catch (e) { + console.log('忽略解析错误:', e); } - } catch (e) { - console.log('忽略解析错误:', e); } } } - } - return processChunk().then(() => { - // 在流处理完成后保存完整的markdown内容 - localStorage.setItem('lastMarkdownContent', accumulatedContent); + return processChunk().then(() => { + // 在流处理完成后保存完整的markdown内容 + localStorage.setItem('lastMarkdownContent', accumulatedContent); + }); }); - }); - } + } - return processChunk(); - }) - .catch(error => { - console.error('Error:', error); - }); + return processChunk(); + }) + .catch(error => { + // 移除加载动画 + answerArea.innerHTML = ''; + + console.error('Error:', error); + // 出错时也移除加载动画 + answerArea.innerHTML = '
请求出错,请重试
'; + }); } function clearAll() { @@ -392,4 +424,5 @@ } - \ No newline at end of file + + diff --git a/dsRag/static/aj.html b/dsRag/static/aj.html deleted file mode 100644 index d78e5339..00000000 --- a/dsRag/static/aj.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - SSE测试 - - - - -
- - - - \ No newline at end of file