@lvce-editor/chat-view 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chatViewWorkerMain.js +33 -4
- package/package.json +1 -1
|
@@ -1508,7 +1508,7 @@ const createDefaultState = () => {
|
|
|
1508
1508
|
messages: [],
|
|
1509
1509
|
title: defaultSessionTitle()
|
|
1510
1510
|
}],
|
|
1511
|
-
streamingEnabled:
|
|
1511
|
+
streamingEnabled: true,
|
|
1512
1512
|
tokensMax: 0,
|
|
1513
1513
|
tokensUsed: 0,
|
|
1514
1514
|
uid: 0,
|
|
@@ -4663,7 +4663,7 @@ const getAiResponse = async ({
|
|
|
4663
4663
|
passIncludeObfuscation = false,
|
|
4664
4664
|
platform,
|
|
4665
4665
|
selectedModelId,
|
|
4666
|
-
streamingEnabled =
|
|
4666
|
+
streamingEnabled = true,
|
|
4667
4667
|
useMockApi,
|
|
4668
4668
|
userText,
|
|
4669
4669
|
webSearchEnabled = false
|
|
@@ -4807,6 +4807,7 @@ const handleClickSaveOpenApiApiKey = async state => {
|
|
|
4807
4807
|
openRouterApiKey: updatedState.openRouterApiKey,
|
|
4808
4808
|
platform: updatedState.platform,
|
|
4809
4809
|
selectedModelId: updatedState.selectedModelId,
|
|
4810
|
+
streamingEnabled: updatedState.streamingEnabled,
|
|
4810
4811
|
useMockApi: updatedState.useMockApi,
|
|
4811
4812
|
userText: previousUserMessage.text
|
|
4812
4813
|
});
|
|
@@ -5751,9 +5752,9 @@ const loadPassIncludeObfuscation = async () => {
|
|
|
5751
5752
|
const loadStreamingEnabled = async () => {
|
|
5752
5753
|
try {
|
|
5753
5754
|
const savedStreamingEnabled = await get('chatView.streamingEnabled');
|
|
5754
|
-
return typeof savedStreamingEnabled === 'boolean' ? savedStreamingEnabled :
|
|
5755
|
+
return typeof savedStreamingEnabled === 'boolean' ? savedStreamingEnabled : true;
|
|
5755
5756
|
} catch {
|
|
5756
|
-
return
|
|
5757
|
+
return true;
|
|
5757
5758
|
}
|
|
5758
5759
|
};
|
|
5759
5760
|
|
|
@@ -6314,6 +6315,15 @@ const getInlineNodeDom = inlineNode => {
|
|
|
6314
6315
|
}, text(inlineNode.text)];
|
|
6315
6316
|
};
|
|
6316
6317
|
|
|
6318
|
+
const getCodeBlockDom = node => {
|
|
6319
|
+
return [{
|
|
6320
|
+
childCount: 1,
|
|
6321
|
+
type: Pre
|
|
6322
|
+
}, {
|
|
6323
|
+
childCount: 1,
|
|
6324
|
+
type: Code
|
|
6325
|
+
}, text(node.text)];
|
|
6326
|
+
};
|
|
6317
6327
|
const getOrderedListItemDom = item => {
|
|
6318
6328
|
return [{
|
|
6319
6329
|
childCount: item.children.length,
|
|
@@ -6366,6 +6376,9 @@ const getMessageNodeDom = node => {
|
|
|
6366
6376
|
if (node.type === 'table') {
|
|
6367
6377
|
return getTableDom(node);
|
|
6368
6378
|
}
|
|
6379
|
+
if (node.type === 'code-block') {
|
|
6380
|
+
return getCodeBlockDom(node);
|
|
6381
|
+
}
|
|
6369
6382
|
return [{
|
|
6370
6383
|
childCount: node.items.length,
|
|
6371
6384
|
className: ChatOrderedList,
|
|
@@ -6918,6 +6931,7 @@ const getToolCallsDom = message => {
|
|
|
6918
6931
|
const orderedListItemRegex = /^\s*\d+\.\s+(.*)$/;
|
|
6919
6932
|
const markdownInlineRegex = /\[([^\]]+)\]\(([^)]+)\)|\*\*([^*]+)\*\*/g;
|
|
6920
6933
|
const markdownTableSeparatorCellRegex = /^:?-{3,}:?$/;
|
|
6934
|
+
const fencedCodeBlockRegex = /^```/;
|
|
6921
6935
|
const normalizeInlineTables = value => {
|
|
6922
6936
|
return value.split(/\r?\n/).map(line => {
|
|
6923
6937
|
if (!line.includes('|')) {
|
|
@@ -7047,6 +7061,21 @@ const parseMessageContent = rawMessage => {
|
|
|
7047
7061
|
flushParagraph();
|
|
7048
7062
|
continue;
|
|
7049
7063
|
}
|
|
7064
|
+
if (fencedCodeBlockRegex.test(line.trim())) {
|
|
7065
|
+
flushList();
|
|
7066
|
+
flushParagraph();
|
|
7067
|
+
const codeLines = [];
|
|
7068
|
+
i++;
|
|
7069
|
+
while (i < lines.length && !fencedCodeBlockRegex.test(lines[i].trim())) {
|
|
7070
|
+
codeLines.push(lines[i]);
|
|
7071
|
+
i++;
|
|
7072
|
+
}
|
|
7073
|
+
nodes.push({
|
|
7074
|
+
text: codeLines.join('\n'),
|
|
7075
|
+
type: 'code-block'
|
|
7076
|
+
});
|
|
7077
|
+
continue;
|
|
7078
|
+
}
|
|
7050
7079
|
if (isTableRow(line) && i + 1 < lines.length) {
|
|
7051
7080
|
const headerCells = getTableCells(line);
|
|
7052
7081
|
if (isTableSeparatorRow(lines[i + 1], headerCells.length)) {
|