feat: RAG 本地知识库 - 向量存储、文档分块、语义检索、知识库管理面板
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
} from './chat-area.js';
|
||||
import { showToast } from './toast.js';
|
||||
import { checkConnection } from './header.js';
|
||||
import { isRagEnabled, performRagRetrieval } from './kb-modal.js';
|
||||
|
||||
let chatInputEl, btnSendEl, fileInputEl, textFileInputEl, imagePreviewEl, filePreviewEl;
|
||||
let pendingImages = [];
|
||||
@@ -400,6 +401,16 @@ export async function sendMessage() {
|
||||
...(numCtx && { options: { num_ctx: numCtx } })
|
||||
};
|
||||
|
||||
// RAG 检索增强
|
||||
if (isRagEnabled()) {
|
||||
const ragResult = await performRagRetrieval(text);
|
||||
if (ragResult && ragResult.ragPrompt) {
|
||||
chatParams.system = chatParams.system
|
||||
? chatParams.system + '\n\n' + ragResult.ragPrompt
|
||||
: ragResult.ragPrompt;
|
||||
}
|
||||
}
|
||||
|
||||
await api.chatStream(chatParams, (chunk) => {
|
||||
if (chunk.message) {
|
||||
if (chunk.message.content) {
|
||||
|
||||
Reference in New Issue
Block a user