Skip to content

Commit 93b00dd

Browse files
authored
Merge pull request #382 from iceljc/features/refine-chat-window
add knowledge data count
2 parents 30a763d + 7170af4 commit 93b00dd

File tree

3 files changed

+56
-24
lines changed

3 files changed

+56
-24
lines changed

src/lib/scss/custom/pages/_knowledgebase.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@
264264
}
265265

266266
.knowledge-table-header {
267+
.knowledge-count {
268+
padding: 0 0.75rem;
269+
}
270+
267271
.knowledge-header-text {
268272
margin-bottom: 0px !important;
269273
padding: 0.47rem 0.75rem;
@@ -276,6 +280,10 @@
276280
gap: 10px;
277281
}
278282

283+
.action-container-padding {
284+
padding: 5px 0px;
285+
}
286+
279287
.collection-dropdown-container {
280288
display: flex;
281289
gap: 5px;

src/routes/page/knowledge-base/documents/+page.svelte

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
/** @type {string | null | undefined } */
7272
let nextId;
7373
74+
/** @type {number | null | undefined} */
75+
let totalDataCount;
76+
7477
/** @type {string} */
7578
let editCollection;
7679
@@ -208,6 +211,7 @@
208211
209212
searchVectorKnowledge(selectedCollection, params).then(res => {
210213
items = res || [];
214+
totalDataCount = items.length;
211215
isFromSearch = true;
212216
}).finally(() => {
213217
isSearching = false;
@@ -367,6 +371,7 @@
367371
items = [ ...items, ...newItems ];
368372
}
369373
nextId = res.next_id;
374+
totalDataCount = res.count;
370375
resolve(res);
371376
}).catch(err => {
372377
console.log(err);
@@ -447,6 +452,9 @@
447452
isComplete = false;
448453
}, duration);
449454
items = items?.filter(x => x.id !== id) || [];
455+
if (totalDataCount) {
456+
totalDataCount -= 1;
457+
}
450458
} else {
451459
throw 'error when deleting vector knowledge!';
452460
}
@@ -1032,10 +1040,15 @@
10321040
<div class="w-100">
10331041
<Card>
10341042
<CardBody>
1035-
<div class="mt-2">
1036-
<div class="d-flex flex-wrap mb-3 justify-content-between knowledge-table-header">
1037-
<div class="d-flex" style="gap: 5px;">
1038-
<h5 class="font-size-16 knowledge-header-text">
1043+
<div class="mt-2 knowledge-table-header">
1044+
{#if totalDataCount != null && totalDataCount != undefined}
1045+
<div class="knowledge-count line-align-center text-muted font-size-11">
1046+
{`Total data: ${Number(totalDataCount).toLocaleString("en-US")}`}
1047+
</div>
1048+
{/if}
1049+
<div class="d-flex flex-wrap mb-3 justify-content-between">
1050+
<div class="action-container-padding d-flex" style="gap: 5px;">
1051+
<h5 class="knowledge-header-text font-size-16">
10391052
<div>{$_('Knowledges')}</div>
10401053
</h5>
10411054
<div
@@ -1044,31 +1057,30 @@
10441057
data-bs-placement="top"
10451058
title="Add knowledge"
10461059
>
1047-
<Button
1048-
class="btn btn-sm btn-soft-primary knowledge-btn-icon"
1060+
<Button
1061+
class="btn btn-sm btn-soft-primary knowledge-btn-icon"
10491062
disabled={disabled}
1050-
on:click={() => onKnowledgeCreate()}
1051-
>
1052-
<i class="mdi mdi-plus" />
1053-
</Button>
1063+
on:click={() => onKnowledgeCreate()}
1064+
>
1065+
<i class="mdi mdi-plus" />
1066+
</Button>
10541067
</div>
10551068
<div
10561069
class="line-align-center"
10571070
data-bs-toggle="tooltip"
10581071
data-bs-placement="top"
10591072
title="Delete all data"
10601073
>
1061-
<Button
1062-
class="btn btn-sm btn-soft-danger knowledge-btn-icon"
1074+
<Button
1075+
class="btn btn-sm btn-soft-danger knowledge-btn-icon"
10631076
disabled={disabled}
1064-
on:click={() => onKnowledgeDeleteAll()}
1065-
>
1066-
<i class="mdi mdi-minus" />
1067-
</Button>
1077+
on:click={() => onKnowledgeDeleteAll()}
1078+
>
1079+
<i class="mdi mdi-minus" />
1080+
</Button>
10681081
</div>
10691082
</div>
1070-
1071-
<div class="collection-action-container">
1083+
<div class="collection-action-container action-container-padding">
10721084
{#if selectedCollection}
10731085
<div
10741086
class="line-align-center"

src/routes/page/knowledge-base/question-answer/+page.svelte

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
/** @type {string | null | undefined } */
7575
let nextId;
7676
77+
/** @type {number | null | undefined} */
78+
let totalDataCount;
79+
7780
/** @type {string} */
7881
let editCollection;
7982
@@ -208,6 +211,7 @@
208211
209212
searchVectorKnowledge(selectedCollection, params).then(res => {
210213
items = res || [];
214+
totalDataCount = items.length;
211215
isFromSearch = true;
212216
}).finally(() => {
213217
isSearching = false;
@@ -368,6 +372,7 @@
368372
items = [ ...items, ...newItems ];
369373
}
370374
nextId = res.next_id;
375+
totalDataCount = res.count;
371376
resolve(res);
372377
}).catch(err => {
373378
console.log(err);
@@ -460,6 +465,9 @@
460465
isComplete = false;
461466
}, duration);
462467
items = items?.filter(x => x.id !== id) || [];
468+
if (totalDataCount) {
469+
totalDataCount -= 1;
470+
}
463471
} else {
464472
throw 'error when deleting vector knowledge!';
465473
}
@@ -1004,10 +1012,15 @@
10041012
<div class="w-100">
10051013
<Card>
10061014
<CardBody>
1007-
<div class="mt-2">
1008-
<div class="d-flex flex-wrap mb-3 justify-content-between knowledge-table-header">
1009-
<div class="d-flex" style="gap: 5px;">
1010-
<h5 class="font-size-16 knowledge-header-text">
1015+
<div class="mt-2 knowledge-table-header">
1016+
{#if totalDataCount != null && totalDataCount != undefined}
1017+
<div class="knowledge-count line-align-center text-muted font-size-11">
1018+
{`Total data: ${Number(totalDataCount).toLocaleString("en-US")}`}
1019+
</div>
1020+
{/if}
1021+
<div class="d-flex flex-wrap mb-3 justify-content-between">
1022+
<div class="action-container-padding d-flex" style="gap: 5px;">
1023+
<h5 class="knowledge-header-text font-size-16">
10111024
<div>{$_('Knowledges')}</div>
10121025
</h5>
10131026
<div
@@ -1039,8 +1052,7 @@
10391052
</Button>
10401053
</div>
10411054
</div>
1042-
1043-
<div class="collection-action-container">
1055+
<div class="collection-action-container action-container-padding">
10441056
{#if selectedCollection}
10451057
<div class="line-align-center">
10461058
<Button

0 commit comments

Comments
 (0)