strapi-content-embeddings 0.1.5 → 0.1.7
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/_chunks/{App-j180lztd.mjs → App-C5NFY1UT.mjs} +256 -70
- package/dist/_chunks/{App-Rq72tIgS.js → App-CA5bQnKQ.js} +255 -69
- package/dist/_chunks/en-B4KWt_jN.js +0 -1
- package/dist/_chunks/en-Byx4XI2L.mjs +0 -1
- package/dist/_chunks/{index-B3j0IFUi.mjs → index-CIpGvEcJ.mjs} +60 -85
- package/dist/_chunks/{index-jf6vikTZ.js → index-CVCA8dDp.js} +57 -82
- package/dist/admin/index.js +1 -2
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/src/components/custom/EmbeddingsTable.d.ts +1 -1
- package/dist/server/index.js +292 -32
- package/dist/server/index.mjs +292 -32
- package/dist/server/src/controllers/controller.d.ts +18 -0
- package/dist/server/src/controllers/index.d.ts +3 -0
- package/dist/server/src/index.d.ts +4 -0
- package/dist/server/src/plugin-manager.d.ts +16 -0
- package/dist/server/src/services/index.d.ts +1 -0
- package/dist/server/src/services/sync.d.ts +23 -0
- package/package.json +1 -1
- package/dist/_chunks/App-Rq72tIgS.js.map +0 -1
- package/dist/_chunks/App-j180lztd.mjs.map +0 -1
- package/dist/_chunks/en-B4KWt_jN.js.map +0 -1
- package/dist/_chunks/en-Byx4XI2L.mjs.map +0 -1
- package/dist/_chunks/index-B3j0IFUi.mjs.map +0 -1
- package/dist/_chunks/index-jf6vikTZ.js.map +0 -1
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/index.mjs.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs.map +0 -1
|
@@ -7,7 +7,7 @@ const react = require("react");
|
|
|
7
7
|
const designSystem = require("@strapi/design-system");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const qs = require("qs");
|
|
10
|
-
const index = require("./index-
|
|
10
|
+
const index = require("./index-CVCA8dDp.js");
|
|
11
11
|
const styled = require("styled-components");
|
|
12
12
|
const ReactMarkdown = require("react-markdown");
|
|
13
13
|
const reactIntl = require("react-intl");
|
|
@@ -104,7 +104,7 @@ function EmbeddingsTable({ data }) {
|
|
|
104
104
|
const handleRowClick = (documentId) => {
|
|
105
105
|
navigate(`/plugins/${index.PLUGIN_ID}/embeddings/${documentId}`);
|
|
106
106
|
};
|
|
107
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding:
|
|
107
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, background: "neutral100", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: data.length + 1, children: [
|
|
108
108
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
109
109
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "ID" }) }),
|
|
110
110
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Title" }) }),
|
|
@@ -468,6 +468,7 @@ function ChatModal() {
|
|
|
468
468
|
] }) })
|
|
469
469
|
] });
|
|
470
470
|
}
|
|
471
|
+
const PAGE_SIZE = 10;
|
|
471
472
|
function debounce(func, wait) {
|
|
472
473
|
let timeout;
|
|
473
474
|
return (...args) => {
|
|
@@ -481,16 +482,20 @@ function HomePage() {
|
|
|
481
482
|
const [embeddings, setEmbeddings] = react.useState(null);
|
|
482
483
|
const [search, setSearch] = react.useState("");
|
|
483
484
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
484
|
-
const
|
|
485
|
+
const [currentPage, setCurrentPage] = react.useState(1);
|
|
486
|
+
const totalPages = embeddings ? Math.ceil(embeddings.totalCount / PAGE_SIZE) : 0;
|
|
487
|
+
const buildQuery = (searchTerm, page) => qs__default.default.stringify({
|
|
488
|
+
page,
|
|
489
|
+
pageSize: PAGE_SIZE,
|
|
485
490
|
filters: searchTerm ? {
|
|
486
491
|
$or: [{ title: { $containsi: searchTerm } }, { content: { $containsi: searchTerm } }]
|
|
487
492
|
} : void 0
|
|
488
493
|
});
|
|
489
494
|
const fetchData = react.useCallback(
|
|
490
|
-
async (searchTerm) => {
|
|
495
|
+
async (searchTerm, page) => {
|
|
491
496
|
setIsLoading(true);
|
|
492
497
|
try {
|
|
493
|
-
const response = await get(`/${index.PLUGIN_ID}/embeddings/find?${buildQuery(searchTerm)}`);
|
|
498
|
+
const response = await get(`/${index.PLUGIN_ID}/embeddings/find?${buildQuery(searchTerm, page)}`);
|
|
494
499
|
setEmbeddings(response.data);
|
|
495
500
|
} catch (error) {
|
|
496
501
|
console.error("Failed to fetch embeddings:", error);
|
|
@@ -503,8 +508,11 @@ function HomePage() {
|
|
|
503
508
|
);
|
|
504
509
|
const debouncedFetch = react.useMemo(() => debounce(fetchData, 500), [fetchData]);
|
|
505
510
|
react.useEffect(() => {
|
|
506
|
-
debouncedFetch(search);
|
|
507
|
-
}, [search, debouncedFetch]);
|
|
511
|
+
debouncedFetch(search, currentPage);
|
|
512
|
+
}, [search, currentPage, debouncedFetch]);
|
|
513
|
+
react.useEffect(() => {
|
|
514
|
+
setCurrentPage(1);
|
|
515
|
+
}, [search]);
|
|
508
516
|
const handleSearchChange = (e) => {
|
|
509
517
|
setSearch(e.target.value);
|
|
510
518
|
};
|
|
@@ -538,12 +546,72 @@ function HomePage() {
|
|
|
538
546
|
'"'
|
|
539
547
|
] });
|
|
540
548
|
};
|
|
549
|
+
const shouldShowPagination = embeddings && embeddings.totalCount > 0 && totalPages > 1;
|
|
550
|
+
const getVisiblePages = () => {
|
|
551
|
+
const pages = [];
|
|
552
|
+
const maxVisible = 5;
|
|
553
|
+
let start = Math.max(1, currentPage - Math.floor(maxVisible / 2));
|
|
554
|
+
const end = Math.min(totalPages, start + maxVisible - 1);
|
|
555
|
+
if (end - start + 1 < maxVisible) {
|
|
556
|
+
start = Math.max(1, end - maxVisible + 1);
|
|
557
|
+
}
|
|
558
|
+
for (let i = start; i <= end; i++) {
|
|
559
|
+
pages.push(i);
|
|
560
|
+
}
|
|
561
|
+
return pages;
|
|
562
|
+
};
|
|
563
|
+
const renderPagination = () => {
|
|
564
|
+
if (!shouldShowPagination || !embeddings) {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
const startItem = (currentPage - 1) * PAGE_SIZE + 1;
|
|
568
|
+
const endItem = Math.min(currentPage * PAGE_SIZE, embeddings.totalCount);
|
|
569
|
+
const visiblePages = getVisiblePages();
|
|
570
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 3, paddingTop: 6, children: [
|
|
571
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Pagination, { activePage: currentPage, pageCount: totalPages, children: [
|
|
572
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
573
|
+
designSystem.PreviousLink,
|
|
574
|
+
{
|
|
575
|
+
onClick: () => setCurrentPage((p) => Math.max(1, p - 1)),
|
|
576
|
+
disabled: currentPage === 1,
|
|
577
|
+
children: "Previous"
|
|
578
|
+
}
|
|
579
|
+
),
|
|
580
|
+
visiblePages.map((page) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
581
|
+
designSystem.PageLink,
|
|
582
|
+
{
|
|
583
|
+
number: page,
|
|
584
|
+
onClick: () => setCurrentPage(page),
|
|
585
|
+
children: page
|
|
586
|
+
},
|
|
587
|
+
page
|
|
588
|
+
)),
|
|
589
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
590
|
+
designSystem.NextLink,
|
|
591
|
+
{
|
|
592
|
+
onClick: () => setCurrentPage((p) => Math.min(totalPages, p + 1)),
|
|
593
|
+
disabled: currentPage === totalPages,
|
|
594
|
+
children: "Next"
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
] }),
|
|
598
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
599
|
+
"Showing ",
|
|
600
|
+
startItem,
|
|
601
|
+
" to ",
|
|
602
|
+
endItem,
|
|
603
|
+
" of ",
|
|
604
|
+
embeddings.totalCount,
|
|
605
|
+
" entries"
|
|
606
|
+
] })
|
|
607
|
+
] });
|
|
608
|
+
};
|
|
541
609
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
|
|
542
610
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
543
611
|
admin.Layouts.Header,
|
|
544
612
|
{
|
|
545
613
|
title: "Content Embeddings",
|
|
546
|
-
subtitle: `${embeddings?.
|
|
614
|
+
subtitle: `${embeddings?.totalCount || 0} embeddings total`,
|
|
547
615
|
primaryAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}), onClick: handleCreateNew, children: "Create new embedding" })
|
|
548
616
|
}
|
|
549
617
|
),
|
|
@@ -558,7 +626,8 @@ function HomePage() {
|
|
|
558
626
|
startAction: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, {})
|
|
559
627
|
}
|
|
560
628
|
) }),
|
|
561
|
-
renderEmbeddingsContent()
|
|
629
|
+
renderEmbeddingsContent(),
|
|
630
|
+
renderPagination()
|
|
562
631
|
] }),
|
|
563
632
|
/* @__PURE__ */ jsxRuntime.jsx(ChatModal, {})
|
|
564
633
|
] });
|
|
@@ -748,6 +817,23 @@ const StyledTypography = styled__default.default(designSystem.Typography)`
|
|
|
748
817
|
display: block;
|
|
749
818
|
margin-bottom: 1rem;
|
|
750
819
|
`;
|
|
820
|
+
const ChunkTab = styled__default.default.div`
|
|
821
|
+
padding: 0.5rem 1rem;
|
|
822
|
+
cursor: pointer;
|
|
823
|
+
border-bottom: 2px solid ${({ $isActive }) => $isActive ? "#4945ff" : "transparent"};
|
|
824
|
+
color: ${({ $isActive }) => $isActive ? "#4945ff" : "inherit"};
|
|
825
|
+
font-weight: ${({ $isActive }) => $isActive ? "600" : "400"};
|
|
826
|
+
white-space: nowrap;
|
|
827
|
+
|
|
828
|
+
&:hover {
|
|
829
|
+
color: #4945ff;
|
|
830
|
+
}
|
|
831
|
+
`;
|
|
832
|
+
const ChunkTabsContainer = styled__default.default(designSystem.Flex)`
|
|
833
|
+
border-bottom: 1px solid #dcdce4;
|
|
834
|
+
overflow-x: auto;
|
|
835
|
+
margin-bottom: 1rem;
|
|
836
|
+
`;
|
|
751
837
|
function Metadata({ data }) {
|
|
752
838
|
const metadata = {
|
|
753
839
|
id: data.documentId,
|
|
@@ -804,6 +890,8 @@ function EmbeddingDetails() {
|
|
|
804
890
|
const { del, get, put } = admin.useFetchClient();
|
|
805
891
|
const { toggleNotification } = admin.useNotification();
|
|
806
892
|
const [data, setData] = react.useState(null);
|
|
893
|
+
const [chunks, setChunks] = react.useState([]);
|
|
894
|
+
const [activeChunkIndex, setActiveChunkIndex] = react.useState(0);
|
|
807
895
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
808
896
|
const [isDeleting, setIsDeleting] = react.useState(false);
|
|
809
897
|
const [isEditing, setIsEditing] = react.useState(false);
|
|
@@ -811,6 +899,8 @@ function EmbeddingDetails() {
|
|
|
811
899
|
const [editTitle, setEditTitle] = react.useState("");
|
|
812
900
|
const [editContent, setEditContent] = react.useState("");
|
|
813
901
|
const [editMetadata, setEditMetadata] = react.useState("");
|
|
902
|
+
const isChunkedDocument = chunks.length > 1;
|
|
903
|
+
const activeChunk = isChunkedDocument ? chunks[activeChunkIndex] : data;
|
|
814
904
|
react.useEffect(() => {
|
|
815
905
|
async function fetchData() {
|
|
816
906
|
if (!id) return;
|
|
@@ -818,9 +908,31 @@ function EmbeddingDetails() {
|
|
|
818
908
|
const response = await get(`/${index.PLUGIN_ID}/embeddings/find/${id}`);
|
|
819
909
|
const embeddingData = response.data;
|
|
820
910
|
setData(embeddingData);
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
911
|
+
const chunksResponse = await get(`/${index.PLUGIN_ID}/embeddings/related-chunks/${id}`);
|
|
912
|
+
const relatedChunks = chunksResponse.data?.data || [];
|
|
913
|
+
if (relatedChunks.length > 1) {
|
|
914
|
+
const sortedChunks = relatedChunks.sort((a, b) => {
|
|
915
|
+
const aIndex = a.metadata?.chunkIndex ?? 0;
|
|
916
|
+
const bIndex = b.metadata?.chunkIndex ?? 0;
|
|
917
|
+
return aIndex - bIndex;
|
|
918
|
+
});
|
|
919
|
+
setChunks(sortedChunks);
|
|
920
|
+
const currentIndex = sortedChunks.findIndex(
|
|
921
|
+
(chunk) => chunk.documentId === id
|
|
922
|
+
);
|
|
923
|
+
if (currentIndex >= 0) {
|
|
924
|
+
setActiveChunkIndex(currentIndex);
|
|
925
|
+
}
|
|
926
|
+
const firstChunk = sortedChunks[currentIndex >= 0 ? currentIndex : 0];
|
|
927
|
+
setEditTitle(firstChunk.title || "");
|
|
928
|
+
setEditContent(firstChunk.content || "");
|
|
929
|
+
setEditMetadata(firstChunk.metadata ? JSON.stringify(firstChunk.metadata, null, 2) : "");
|
|
930
|
+
} else {
|
|
931
|
+
setChunks([embeddingData]);
|
|
932
|
+
setEditTitle(embeddingData.title || "");
|
|
933
|
+
setEditContent(embeddingData.content || "");
|
|
934
|
+
setEditMetadata(embeddingData.metadata ? JSON.stringify(embeddingData.metadata, null, 2) : "");
|
|
935
|
+
}
|
|
824
936
|
} catch (error) {
|
|
825
937
|
console.error("Failed to fetch embedding:", error);
|
|
826
938
|
} finally {
|
|
@@ -829,11 +941,24 @@ function EmbeddingDetails() {
|
|
|
829
941
|
}
|
|
830
942
|
fetchData();
|
|
831
943
|
}, [id, get]);
|
|
944
|
+
react.useEffect(() => {
|
|
945
|
+
if (activeChunk && !isEditing) {
|
|
946
|
+
setEditTitle(activeChunk.title || "");
|
|
947
|
+
setEditContent(activeChunk.content || "");
|
|
948
|
+
setEditMetadata(activeChunk.metadata ? JSON.stringify(activeChunk.metadata, null, 2) : "");
|
|
949
|
+
}
|
|
950
|
+
}, [activeChunkIndex, activeChunk, isEditing]);
|
|
832
951
|
const handleDelete = async () => {
|
|
833
|
-
if (!
|
|
952
|
+
if (!activeChunk || isDeleting) return;
|
|
834
953
|
setIsDeleting(true);
|
|
835
954
|
try {
|
|
836
|
-
|
|
955
|
+
if (isChunkedDocument) {
|
|
956
|
+
for (const chunk of chunks) {
|
|
957
|
+
await del(`/${index.PLUGIN_ID}/embeddings/delete-embedding/${chunk.documentId}`);
|
|
958
|
+
}
|
|
959
|
+
} else {
|
|
960
|
+
await del(`/${index.PLUGIN_ID}/embeddings/delete-embedding/${activeChunk.documentId}`);
|
|
961
|
+
}
|
|
837
962
|
navigate(`/plugins/${index.PLUGIN_ID}`);
|
|
838
963
|
} catch (error) {
|
|
839
964
|
console.error("Failed to delete embedding:", error);
|
|
@@ -841,18 +966,23 @@ function EmbeddingDetails() {
|
|
|
841
966
|
}
|
|
842
967
|
};
|
|
843
968
|
const handleStartEdit = () => {
|
|
844
|
-
if (
|
|
845
|
-
setEditTitle(
|
|
846
|
-
setEditContent(
|
|
847
|
-
setEditMetadata(
|
|
969
|
+
if (activeChunk) {
|
|
970
|
+
setEditTitle(activeChunk.title || "");
|
|
971
|
+
setEditContent(activeChunk.content || "");
|
|
972
|
+
setEditMetadata(activeChunk.metadata ? JSON.stringify(activeChunk.metadata, null, 2) : "");
|
|
848
973
|
}
|
|
849
974
|
setIsEditing(true);
|
|
850
975
|
};
|
|
851
976
|
const handleCancelEdit = () => {
|
|
852
977
|
setIsEditing(false);
|
|
978
|
+
if (activeChunk) {
|
|
979
|
+
setEditTitle(activeChunk.title || "");
|
|
980
|
+
setEditContent(activeChunk.content || "");
|
|
981
|
+
setEditMetadata(activeChunk.metadata ? JSON.stringify(activeChunk.metadata, null, 2) : "");
|
|
982
|
+
}
|
|
853
983
|
};
|
|
854
984
|
const handleSave = async () => {
|
|
855
|
-
if (!
|
|
985
|
+
if (!activeChunk || isSaving) return;
|
|
856
986
|
let parsedMetadata = null;
|
|
857
987
|
if (editMetadata.trim()) {
|
|
858
988
|
try {
|
|
@@ -867,18 +997,26 @@ function EmbeddingDetails() {
|
|
|
867
997
|
}
|
|
868
998
|
setIsSaving(true);
|
|
869
999
|
try {
|
|
870
|
-
const response = await put(`/${index.PLUGIN_ID}/embeddings/update-embedding/${
|
|
1000
|
+
const response = await put(`/${index.PLUGIN_ID}/embeddings/update-embedding/${activeChunk.documentId}`, {
|
|
871
1001
|
data: {
|
|
872
1002
|
title: editTitle.trim(),
|
|
873
1003
|
content: editContent.trim(),
|
|
874
1004
|
metadata: parsedMetadata
|
|
875
1005
|
}
|
|
876
1006
|
});
|
|
877
|
-
|
|
1007
|
+
const updatedData = response.data;
|
|
1008
|
+
if (isChunkedDocument) {
|
|
1009
|
+
const newChunks = [...chunks];
|
|
1010
|
+
newChunks[activeChunkIndex] = updatedData;
|
|
1011
|
+
setChunks(newChunks);
|
|
1012
|
+
} else {
|
|
1013
|
+
setData(updatedData);
|
|
1014
|
+
setChunks([updatedData]);
|
|
1015
|
+
}
|
|
878
1016
|
setIsEditing(false);
|
|
879
1017
|
toggleNotification({
|
|
880
1018
|
type: "success",
|
|
881
|
-
message: "
|
|
1019
|
+
message: "Chunk updated successfully"
|
|
882
1020
|
});
|
|
883
1021
|
} catch (error) {
|
|
884
1022
|
console.error("Failed to update embedding:", error);
|
|
@@ -890,6 +1028,20 @@ function EmbeddingDetails() {
|
|
|
890
1028
|
setIsSaving(false);
|
|
891
1029
|
}
|
|
892
1030
|
};
|
|
1031
|
+
const handleChunkSelect = (index2) => {
|
|
1032
|
+
if (isEditing) {
|
|
1033
|
+
const confirmed = globalThis.confirm("You have unsaved changes. Discard them?");
|
|
1034
|
+
if (!confirmed) return;
|
|
1035
|
+
setIsEditing(false);
|
|
1036
|
+
}
|
|
1037
|
+
setActiveChunkIndex(index2);
|
|
1038
|
+
};
|
|
1039
|
+
const getOriginalTitle = () => {
|
|
1040
|
+
if (isChunkedDocument && chunks[0]?.metadata) {
|
|
1041
|
+
return chunks[0].metadata.originalTitle || chunks[0].title?.replace(/\s*\[Part \d+\/\d+\]$/, "");
|
|
1042
|
+
}
|
|
1043
|
+
return data?.title || "Embedding Details";
|
|
1044
|
+
};
|
|
893
1045
|
if (isLoading) {
|
|
894
1046
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
|
|
895
1047
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -902,7 +1054,7 @@ function EmbeddingDetails() {
|
|
|
902
1054
|
/* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: "Loading embedding details..." }) }) })
|
|
903
1055
|
] });
|
|
904
1056
|
}
|
|
905
|
-
if (!data) {
|
|
1057
|
+
if (!data || !activeChunk) {
|
|
906
1058
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
|
|
907
1059
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
908
1060
|
admin.Layouts.Header,
|
|
@@ -914,68 +1066,103 @@ function EmbeddingDetails() {
|
|
|
914
1066
|
/* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 8, textAlign: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "The requested embedding could not be found." }) }) })
|
|
915
1067
|
] });
|
|
916
1068
|
}
|
|
1069
|
+
const headerTitle = isEditing ? `Edit: ${activeChunk.title}` : isChunkedDocument ? getOriginalTitle() : data.title || "Embedding Details";
|
|
1070
|
+
const headerSubtitle = isChunkedDocument ? `Chunked Document (${chunks.length} parts)` : `Embedding ID: ${data.embeddingId || "N/A"}`;
|
|
917
1071
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
|
|
918
1072
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
919
1073
|
admin.Layouts.Header,
|
|
920
1074
|
{
|
|
921
|
-
title:
|
|
922
|
-
subtitle:
|
|
1075
|
+
title: headerTitle,
|
|
1076
|
+
subtitle: headerSubtitle,
|
|
923
1077
|
primaryAction: isEditing ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
924
1078
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}), onClick: handleCancelEdit, children: "Cancel" }),
|
|
925
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}), onClick: handleSave, loading: isSaving, children: isSaving ? "Saving..." : "Save" })
|
|
1079
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}), onClick: handleSave, loading: isSaving, children: isSaving ? "Saving..." : "Save Chunk" })
|
|
926
1080
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
927
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1081
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}), onClick: handleStartEdit, children: [
|
|
1082
|
+
"Edit ",
|
|
1083
|
+
isChunkedDocument ? "Chunk" : ""
|
|
1084
|
+
] }),
|
|
928
1085
|
/* @__PURE__ */ jsxRuntime.jsx(ConfirmDeleteEmbedding, { onConfirm: handleDelete, isLoading: isDeleting })
|
|
929
1086
|
] }),
|
|
930
1087
|
navigationAction: /* @__PURE__ */ jsxRuntime.jsx(BackLink, { to: `/plugins/${index.PLUGIN_ID}` })
|
|
931
1088
|
}
|
|
932
1089
|
),
|
|
933
|
-
/* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.
|
|
934
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
935
|
-
/* @__PURE__ */ jsxRuntime.
|
|
936
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
1090
|
+
/* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 8, children: [
|
|
1091
|
+
isChunkedDocument && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { background: "neutral0", padding: 4, hasRadius: true, children: [
|
|
1092
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, children: [
|
|
1093
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Document Chunks" }),
|
|
1094
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { children: [
|
|
1095
|
+
chunks.length,
|
|
1096
|
+
" parts"
|
|
1097
|
+
] })
|
|
1098
|
+
] }),
|
|
1099
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChunkTabsContainer, { gap: 0, children: chunks.map((chunk, index2) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1100
|
+
ChunkTab,
|
|
1101
|
+
{
|
|
1102
|
+
$isActive: index2 === activeChunkIndex,
|
|
1103
|
+
onClick: () => handleChunkSelect(index2),
|
|
1104
|
+
children: [
|
|
1105
|
+
"Part ",
|
|
1106
|
+
index2 + 1,
|
|
1107
|
+
index2 === activeChunkIndex && isEditing && " (editing)"
|
|
1108
|
+
]
|
|
1109
|
+
},
|
|
1110
|
+
chunk.documentId
|
|
1111
|
+
)) })
|
|
1112
|
+
] }) }),
|
|
1113
|
+
isEditing ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 6, children: [
|
|
1114
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 8, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 1, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, children: [
|
|
1115
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Title" }),
|
|
1117
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1118
|
+
designSystem.TextInput,
|
|
1119
|
+
{
|
|
1120
|
+
value: editTitle,
|
|
1121
|
+
onChange: (e) => setEditTitle(e.target.value)
|
|
1122
|
+
}
|
|
1123
|
+
)
|
|
1124
|
+
] }) }),
|
|
1125
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { marginBottom: 4, children: [
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
1127
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Content" }),
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: "Changes to content will regenerate the embedding vector" })
|
|
1129
|
+
] }),
|
|
1130
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1131
|
+
index.MarkdownEditor,
|
|
1132
|
+
{
|
|
1133
|
+
content: editContent,
|
|
1134
|
+
onChange: setEditContent,
|
|
1135
|
+
height: 300
|
|
1136
|
+
}
|
|
1137
|
+
)
|
|
1138
|
+
] })
|
|
1139
|
+
] }) }) }),
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 1, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
1141
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Metadata (JSON)" }),
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: "Optional custom metadata" }),
|
|
937
1143
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
938
|
-
designSystem.
|
|
1144
|
+
designSystem.Textarea,
|
|
939
1145
|
{
|
|
940
|
-
value:
|
|
941
|
-
onChange: (e) =>
|
|
1146
|
+
value: editMetadata,
|
|
1147
|
+
onChange: (e) => setEditMetadata(e.target.value),
|
|
1148
|
+
placeholder: '{"key": "value"}'
|
|
942
1149
|
}
|
|
943
1150
|
)
|
|
944
|
-
] }) })
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1151
|
+
] }) }) }) }) })
|
|
1152
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 6, children: [
|
|
1153
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 8, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 1, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, children: [
|
|
1154
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, children: [
|
|
1155
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledTypography, { variant: "beta", style: { margin: 0 }, children: isChunkedDocument ? `Part ${activeChunkIndex + 1} Content` : "Embedding Content" }),
|
|
1156
|
+
isChunkedDocument && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
1157
|
+
activeChunk.content?.length || 0,
|
|
1158
|
+
" characters"
|
|
1159
|
+
] })
|
|
949
1160
|
] }),
|
|
950
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
height: 300
|
|
956
|
-
}
|
|
957
|
-
)
|
|
958
|
-
] })
|
|
959
|
-
] }) }) }),
|
|
960
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 1, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
961
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Metadata (JSON)" }),
|
|
962
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: "Optional custom metadata" }),
|
|
963
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
964
|
-
designSystem.Textarea,
|
|
965
|
-
{
|
|
966
|
-
value: editMetadata,
|
|
967
|
-
onChange: (e) => setEditMetadata(e.target.value),
|
|
968
|
-
placeholder: '{"key": "value"}'
|
|
969
|
-
}
|
|
970
|
-
)
|
|
971
|
-
] }) }) }) }) })
|
|
972
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 6, children: [
|
|
973
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 8, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 1, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, children: [
|
|
974
|
-
/* @__PURE__ */ jsxRuntime.jsx(StyledTypography, { variant: "beta", children: "Embedding Content" }),
|
|
975
|
-
data.content ? /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: data.content }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "No content" })
|
|
976
|
-
] }) }) }),
|
|
977
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 1, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(Metadata, { data }) }) })
|
|
978
|
-
] }) }) })
|
|
1161
|
+
activeChunk.content ? /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: activeChunk.content }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "No content" })
|
|
1162
|
+
] }) }) }),
|
|
1163
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 1, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(Metadata, { data: activeChunk }) }) })
|
|
1164
|
+
] })
|
|
1165
|
+
] }) })
|
|
979
1166
|
] });
|
|
980
1167
|
}
|
|
981
1168
|
const App = () => {
|
|
@@ -987,4 +1174,3 @@ const App = () => {
|
|
|
987
1174
|
] });
|
|
988
1175
|
};
|
|
989
1176
|
exports.App = App;
|
|
990
|
-
//# sourceMappingURL=App-Rq72tIgS.js.map
|