diff --git a/dsRag/Config/__pycache__/Config.cpython-310.pyc b/dsRag/Config/__pycache__/Config.cpython-310.pyc index aba3f494..e244bc21 100644 Binary files a/dsRag/Config/__pycache__/Config.cpython-310.pyc and b/dsRag/Config/__pycache__/Config.cpython-310.pyc differ diff --git a/dsRag/Config/__pycache__/__init__.cpython-310.pyc b/dsRag/Config/__pycache__/__init__.cpython-310.pyc index 2278514c..b3f99ca7 100644 Binary files a/dsRag/Config/__pycache__/__init__.cpython-310.pyc and b/dsRag/Config/__pycache__/__init__.cpython-310.pyc differ diff --git a/dsRag/ElasticSearch/Utils/__pycache__/ElasticsearchConnectionPool.cpython-310.pyc b/dsRag/ElasticSearch/Utils/__pycache__/ElasticsearchConnectionPool.cpython-310.pyc index 6b078800..2c77d6cb 100644 Binary files a/dsRag/ElasticSearch/Utils/__pycache__/ElasticsearchConnectionPool.cpython-310.pyc and b/dsRag/ElasticSearch/Utils/__pycache__/ElasticsearchConnectionPool.cpython-310.pyc differ diff --git a/dsRag/ElasticSearch/__pycache__/__init__.cpython-310.pyc b/dsRag/ElasticSearch/__pycache__/__init__.cpython-310.pyc index f7c5e0e6..94ae6ce2 100644 Binary files a/dsRag/ElasticSearch/__pycache__/__init__.cpython-310.pyc and b/dsRag/ElasticSearch/__pycache__/__init__.cpython-310.pyc differ diff --git a/dsRag/Util/__pycache__/EsSearchUtil.cpython-310.pyc b/dsRag/Util/__pycache__/EsSearchUtil.cpython-310.pyc index 75397822..8d10dd86 100644 Binary files a/dsRag/Util/__pycache__/EsSearchUtil.cpython-310.pyc and b/dsRag/Util/__pycache__/EsSearchUtil.cpython-310.pyc differ diff --git a/dsRag/Util/__pycache__/SearchUtil.cpython-310.pyc b/dsRag/Util/__pycache__/SearchUtil.cpython-310.pyc index ab6219cd..006f496a 100644 Binary files a/dsRag/Util/__pycache__/SearchUtil.cpython-310.pyc and b/dsRag/Util/__pycache__/SearchUtil.cpython-310.pyc differ diff --git a/dsRag/Util/__pycache__/__init__.cpython-310.pyc b/dsRag/Util/__pycache__/__init__.cpython-310.pyc index 2089b6b5..79767003 100644 Binary files a/dsRag/Util/__pycache__/__init__.cpython-310.pyc and b/dsRag/Util/__pycache__/__init__.cpython-310.pyc differ diff --git a/dsRag/static/ai.html b/dsRag/static/ai.html index 058cfd86..399e7287 100644 --- a/dsRag/static/ai.html +++ b/dsRag/static/ai.html @@ -168,6 +168,34 @@ height: auto; overflow-y: auto; /* 添加滚动条 */ } + + .loading-animation { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 200px; + color: #666; + } + + .spinner { + width: 40px; + height: 40px; + border: 4px solid #f3f3f3; + border-top: 4px solid #3498db; + border-radius: 50%; + animation: spin 1s linear infinite; + margin-bottom: 10px; + } + + @keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } + } @@ -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