fix: kb message truncate bug fix
This commit is contained in:
@@ -574,10 +574,17 @@ export function ChatInterface() {
|
||||
let cleanContent = m.content || "";
|
||||
// Remove injected system prompt instructions from user messages if present
|
||||
if (m.role === 'user') {
|
||||
cleanContent = cleanContent.replace(/^\[System:.*?\]\n?/i, '');
|
||||
// Handle cases where there might be a runtime context block for skills
|
||||
cleanContent = cleanContent.replace(/\[Runtime Context[\s\S]*?(?=\[System:|$)/i, '');
|
||||
cleanContent = cleanContent.replace(/\[System:.*?\]\n?/i, ''); // clean again in case it follows context
|
||||
if (cleanContent.startsWith("[Runtime Context")) {
|
||||
const splitIndex = cleanContent.indexOf("\n\n");
|
||||
if (splitIndex !== -1) {
|
||||
cleanContent = cleanContent.substring(splitIndex + 2);
|
||||
} else {
|
||||
cleanContent = "";
|
||||
}
|
||||
} else if (cleanContent.startsWith("[System:")) {
|
||||
// Fallback for older messages containing [System: ...] wrapper
|
||||
cleanContent = cleanContent.replace(/^\[System:[\s\S]*?\]\n*/i, '');
|
||||
}
|
||||
cleanContent = cleanContent.trim();
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
"knowledgeDocumentDeleteFailed": "Failed to delete document",
|
||||
"noKnowledgeDocuments": "No documents in this knowledge base",
|
||||
"knowledgeDocumentUploadTitle": "Upload Documents to Knowledge Base",
|
||||
"knowledgeDocumentUploadHint": "Supports txt, md, json, yaml, xml, html, csv, xls, xlsx. Max 5MB per file.",
|
||||
"knowledgeDocumentUploadHint": "Supports Text/Markdown/Code, Office(Word/Excel/PPT) and PDF. Max 15MB per file.",
|
||||
"knowledgeDocumentUploadSelected": "{{count}} file(s) selected",
|
||||
"knowledgeDocumentUploadNone": "No files selected",
|
||||
"knowledgeDocumentUploadAction": "Upload and Add",
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
"knowledgeDocumentDeleteFailed": "删除文档失败",
|
||||
"noKnowledgeDocuments": "当前知识库还没有文档",
|
||||
"knowledgeDocumentUploadTitle": "上传文档到知识库",
|
||||
"knowledgeDocumentUploadHint": "支持 txt、md、json、yaml、xml、html、csv、xls、xlsx,单文件不超过 5MB。",
|
||||
"knowledgeDocumentUploadHint": "支持 文本/Markdown/代码、Office (Word/Excel/PPT) 及 PDF 文件,单文件不超过 15MB。",
|
||||
"knowledgeDocumentUploadSelected": "已选择 {{count}} 个文件",
|
||||
"knowledgeDocumentUploadNone": "尚未选择文件",
|
||||
"knowledgeDocumentUploadAction": "上传并入库",
|
||||
|
||||
@@ -499,7 +499,8 @@ export function KnowledgeBases() {
|
||||
<div className="flex-1 overflow-y-auto p-6 space-y-6">
|
||||
{/* Upload Section */}
|
||||
<div className="rounded-lg border border-border p-4 bg-muted/30">
|
||||
<div className="text-sm font-medium text-foreground mb-3">{t('knowledgeDocumentUploadTitle')}</div>
|
||||
<div className="text-sm font-medium text-foreground mb-1">{t('knowledgeDocumentUploadTitle')}</div>
|
||||
<div className="text-xs text-muted-foreground mb-3">{t('knowledgeDocumentUploadHint')}</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<Input
|
||||
type="file"
|
||||
|
||||
Reference in New Issue
Block a user