Browse Source

Merge remote-tracking branch 'origin/master'

dev-mcp
wanghanlin 3 weeks ago
parent
commit
f666c3c248
  1. 8
      client/dist/chatbot-sdk.js
  2. 2
      client/dist/chatbot-sdk.min.js
  3. 8
      client/src/chat.ts
  4. 2
      client/src/config.ts
  5. 4
      client/src/types.ts
  6. 8
      src/main/resources/static/sdk/chatbot-sdk.js
  7. 2
      src/main/resources/static/sdk/chatbot-sdk.min.js
  8. 6
      src/main/resources/static/sdk/test.html

8
client/dist/chatbot-sdk.js

@ -3472,7 +3472,7 @@ var ChatbotSDK = (function () {
hideLoadingFn$1 = dom.hideLoading;
// 初始化知识库分类
currentCategoryId = cfg.categoryId;
useRag = !!cfg.enableRag || !!cfg.categoryId || !!cfg.showCategorySwitch;
useRag = cfg.enableRag;
// 绑定发送事件
bindSendEvents();
// 绑定滚动监听(智能滚动 + 新消息提示)
@ -3784,8 +3784,8 @@ var ChatbotSDK = (function () {
await initChatId();
}
const aiTimestamp = now();
// RAG 启用条件:显式开启 enableRag,或已选择知识库分类
const shouldUseRag = useRag && (config$1.enableRag || currentCategoryId !== undefined || config$1.categoryId !== undefined);
// RAG 启用条件:由 enableRag 控制
const shouldUseRag = useRag;
// 显示 loading
if (showLoadingFn$1)
showLoadingFn$1();
@ -4060,7 +4060,7 @@ var ChatbotSDK = (function () {
/** 设置当前知识库分类 */
function setCategory(categoryId) {
currentCategoryId = categoryId;
useRag = categoryId !== undefined;
useRag = config$1?.enableRag ?? true;
logger.lifecycleCategoryChange(categoryId !== null && categoryId !== void 0 ? categoryId : '全部');
}
// ==================== 会话管理面板 ====================

2
client/dist/chatbot-sdk.min.js
File diff suppressed because it is too large
View File

8
client/src/chat.ts

@ -111,7 +111,7 @@ export function initChat(
// 初始化知识库分类
currentCategoryId = cfg.categoryId;
useRag = !!cfg.enableRag || !!cfg.categoryId || !!cfg.showCategorySwitch;
useRag = cfg.enableRag;
// 绑定发送事件
bindSendEvents();
@ -442,8 +442,8 @@ async function produceAIReply(userText: string): Promise<void> {
}
const aiTimestamp = now();
// RAG 启用条件:显式开启 enableRag,或已选择知识库分类
const shouldUseRag = useRag && (config.enableRag || currentCategoryId !== undefined || config.categoryId !== undefined);
// RAG 启用条件:由 enableRag 控制
const shouldUseRag = useRag;
// 显示 loading
if (showLoadingFn) showLoadingFn();
@ -717,7 +717,7 @@ function generateNewChatId(): string {
/** 设置当前知识库分类 */
export function setCategory(categoryId: number | undefined): void {
currentCategoryId = categoryId;
useRag = categoryId !== undefined;
useRag = config?.enableRag ?? true;
logger.lifecycleCategoryChange(categoryId ?? '全部');
}

2
client/src/config.ts

@ -179,7 +179,7 @@ export function parseConfig(raw: SDKConfig): ResolvedConfig | null {
showTeaser: raw.showTeaser ?? true,
teaserText: (typeof raw.teaserText === 'string' && raw.teaserText.trim()) || '',
streaming: raw.streaming ?? true,
enableRag: raw.enableRag ?? false,
enableRag: raw.enableRag ?? true,
rewriteStrategy: raw.rewriteStrategy || 'REWRITE',
locale: raw.locale || 'zh-CN',
debug: raw.debug ?? true,

4
client/src/types.ts

@ -57,12 +57,12 @@ export interface SDKConfig {
/** 是否启用流式输出,默认 true */
streaming?: boolean;
/**
* RAG false
* RAG true
* 使 /chat/rag/sse
*
*/
enableRag?: boolean;
/** RAG 查询重写策略,默认 "REWRITE"(在 enableRag=true 时生效) */
/** RAG 查询重写策略,默认 "REWRITE"(在 enableRag=true 时生效) */
rewriteStrategy?: 'NONE' | 'REWRITE' | 'TRANSLATION' | 'COMPRESSION' | 'MULTI_QUERY';
/** 界面语言,默认 "zh-CN" */
locale?: string;

8
src/main/resources/static/sdk/chatbot-sdk.js

@ -3472,7 +3472,7 @@ var ChatbotSDK = (function () {
hideLoadingFn$1 = dom.hideLoading;
// 初始化知识库分类
currentCategoryId = cfg.categoryId;
useRag = !!cfg.enableRag || !!cfg.categoryId || !!cfg.showCategorySwitch;
useRag = cfg.enableRag;
// 绑定发送事件
bindSendEvents();
// 绑定滚动监听(智能滚动 + 新消息提示)
@ -3784,8 +3784,8 @@ var ChatbotSDK = (function () {
await initChatId();
}
const aiTimestamp = now();
// RAG 启用条件:显式开启 enableRag,或已选择知识库分类
const shouldUseRag = useRag && (config$1.enableRag || currentCategoryId !== undefined || config$1.categoryId !== undefined);
// RAG 启用条件:由 enableRag 控制
const shouldUseRag = useRag;
// 显示 loading
if (showLoadingFn$1)
showLoadingFn$1();
@ -4060,7 +4060,7 @@ var ChatbotSDK = (function () {
/** 设置当前知识库分类 */
function setCategory(categoryId) {
currentCategoryId = categoryId;
useRag = categoryId !== undefined;
useRag = config$1?.enableRag ?? true;
logger.lifecycleCategoryChange(categoryId !== null && categoryId !== void 0 ? categoryId : '全部');
}
// ==================== 会话管理面板 ====================

2
src/main/resources/static/sdk/chatbot-sdk.min.js
File diff suppressed because it is too large
View File

6
src/main/resources/static/sdk/test.html

@ -162,7 +162,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
</div>
<div class="fg">
<label>enableRag 知识库检索</label>
<select id="cfg-rag"><option value="0" selected>关闭</option><option value="1">开启</option></select>
<select id=cfg-rag><option value=1 selected>开启</option><option value=0>关闭</option></select>
</div>
</div>
<div class="fg-row">
@ -204,7 +204,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
3. chatId 自动管理:从 /conversation/list 获取或自动生成<br>
4. 对话历史从后端加载(点击头部时钟图标查看)<br>
5. AI 回复支持 Markdown 渲染<br>
6. 开启 showCategorySwitch 可选择知识库分类
6. SDK 默认启用 RAG 检索;开启 showCategorySwitch 可选择知识库分类
</div>
<hr class="divider">
@ -330,7 +330,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
streaming: true,
locale: 'zh-CN',
showCategorySwitch: false,
enableRag: false,
enableRag: true,
};
// 生成 Script 片段代码(纯文本)

Loading…
Cancel
Save