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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useEffect, useState } from "react";
|
|
3
|
-
import { Box, Typography, Loader,
|
|
2
|
+
import { useRef, useEffect, useState, useCallback } from "react";
|
|
3
|
+
import { Box, Typography, Loader, Button, Modal, Field, TextInput } from "@strapi/design-system";
|
|
4
4
|
import { useNavigate } from "react-router-dom";
|
|
5
5
|
import styled, { createGlobalStyle } from "styled-components";
|
|
6
6
|
import qs from "qs";
|
|
7
7
|
import { useFetchClient, useNotification, unstable_useContentManagerContext } from "@strapi/strapi/admin";
|
|
8
|
-
import { Eye,
|
|
8
|
+
import { Eye, Plus } from "@strapi/icons";
|
|
9
9
|
import { MDXEditor, headingsPlugin, listsPlugin, quotePlugin, thematicBreakPlugin, linkPlugin, linkDialogPlugin, markdownShortcutPlugin, toolbarPlugin, UndoRedo, Separator, BlockTypeSelect, BoldItalicUnderlineToggles, CreateLink, ListsToggle } from "@mdxeditor/editor";
|
|
10
10
|
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
11
11
|
const v = glob[path];
|
|
@@ -428,14 +428,13 @@ const StyledTypography = styled(Typography)`
|
|
|
428
428
|
`;
|
|
429
429
|
const CHUNK_SIZE = 4e3;
|
|
430
430
|
function EmbeddingsModal() {
|
|
431
|
-
const { post, get
|
|
431
|
+
const { post, get } = useFetchClient();
|
|
432
432
|
const { toggleNotification } = useNotification();
|
|
433
433
|
const navigate = useNavigate();
|
|
434
434
|
const context = unstable_useContentManagerContext();
|
|
435
435
|
const { form, id, slug, collectionType } = context;
|
|
436
436
|
const modifiedValues = form?.values || {};
|
|
437
437
|
const [isVisible, setIsVisible] = useState(false);
|
|
438
|
-
const [isUpdateMode, setIsUpdateMode] = useState(false);
|
|
439
438
|
const [title, setTitle] = useState("");
|
|
440
439
|
const [content, setContent] = useState("");
|
|
441
440
|
const [fieldName, setFieldName] = useState("");
|
|
@@ -451,18 +450,16 @@ function EmbeddingsModal() {
|
|
|
451
450
|
try {
|
|
452
451
|
const query = qs.stringify({
|
|
453
452
|
filters: {
|
|
454
|
-
$
|
|
455
|
-
{ collectionType: { $eq: slug } },
|
|
456
|
-
{ metadata: { $containsi: id } }
|
|
457
|
-
]
|
|
453
|
+
metadata: { $containsi: id }
|
|
458
454
|
}
|
|
459
455
|
});
|
|
460
456
|
const response = await get(`/${PLUGIN_ID}/embeddings/find?${query}`);
|
|
461
|
-
|
|
457
|
+
const embeddings = response.data?.data || response.data || [];
|
|
458
|
+
if (Array.isArray(embeddings) && embeddings.length > 0) {
|
|
462
459
|
setExistingEmbedding({
|
|
463
|
-
documentId:
|
|
464
|
-
title:
|
|
465
|
-
content:
|
|
460
|
+
documentId: embeddings[0].documentId,
|
|
461
|
+
title: embeddings[0].title,
|
|
462
|
+
content: embeddings[0].content
|
|
466
463
|
});
|
|
467
464
|
}
|
|
468
465
|
} catch (error) {
|
|
@@ -473,16 +470,15 @@ function EmbeddingsModal() {
|
|
|
473
470
|
}
|
|
474
471
|
checkExistingEmbedding();
|
|
475
472
|
}, [id, slug, get]);
|
|
476
|
-
|
|
477
|
-
if (!modifiedValues) return;
|
|
473
|
+
const extractContentFromForm = useCallback(() => {
|
|
474
|
+
if (!modifiedValues) return "";
|
|
478
475
|
const textFieldNames = ["content", "description", "body", "text", "richtext", "markdown"];
|
|
479
|
-
for (const
|
|
480
|
-
const value = modifiedValues[
|
|
476
|
+
for (const name of textFieldNames) {
|
|
477
|
+
const value = modifiedValues[name];
|
|
481
478
|
if (value) {
|
|
482
|
-
setFieldName(fieldName2);
|
|
483
479
|
if (typeof value === "string" && value.trim()) {
|
|
484
|
-
|
|
485
|
-
|
|
480
|
+
setFieldName(name);
|
|
481
|
+
return value;
|
|
486
482
|
} else if (Array.isArray(value)) {
|
|
487
483
|
const text = value.map((block) => {
|
|
488
484
|
if (block.children) {
|
|
@@ -491,13 +487,20 @@ function EmbeddingsModal() {
|
|
|
491
487
|
return "";
|
|
492
488
|
}).join("\n\n");
|
|
493
489
|
if (text.trim()) {
|
|
494
|
-
|
|
495
|
-
|
|
490
|
+
setFieldName(name);
|
|
491
|
+
return text;
|
|
496
492
|
}
|
|
497
493
|
}
|
|
498
494
|
}
|
|
499
495
|
}
|
|
496
|
+
return "";
|
|
500
497
|
}, [modifiedValues]);
|
|
498
|
+
useEffect(() => {
|
|
499
|
+
const formContent = extractContentFromForm();
|
|
500
|
+
if (formContent) {
|
|
501
|
+
setContent(formContent);
|
|
502
|
+
}
|
|
503
|
+
}, [extractContentFromForm]);
|
|
501
504
|
const contentLength = content.length;
|
|
502
505
|
const willChunk = contentLength > CHUNK_SIZE;
|
|
503
506
|
const estimatedChunks = willChunk ? Math.ceil(contentLength / (CHUNK_SIZE - 200)) : 1;
|
|
@@ -513,16 +516,12 @@ function EmbeddingsModal() {
|
|
|
513
516
|
}
|
|
514
517
|
const isValid = title.trim() && content.trim();
|
|
515
518
|
function handleOpenCreate() {
|
|
516
|
-
setIsUpdateMode(false);
|
|
517
519
|
setTitle("");
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (existingEmbedding) {
|
|
522
|
-
setIsUpdateMode(true);
|
|
523
|
-
setTitle(existingEmbedding.title);
|
|
524
|
-
setIsVisible(true);
|
|
520
|
+
const formContent = extractContentFromForm();
|
|
521
|
+
if (formContent) {
|
|
522
|
+
setContent(formContent);
|
|
525
523
|
}
|
|
524
|
+
setIsVisible(true);
|
|
526
525
|
}
|
|
527
526
|
async function handleSubmit(e) {
|
|
528
527
|
e.preventDefault();
|
|
@@ -542,50 +541,38 @@ function EmbeddingsModal() {
|
|
|
542
541
|
}
|
|
543
542
|
setIsLoading(true);
|
|
544
543
|
try {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
} else {
|
|
564
|
-
const result = await post(`/${PLUGIN_ID}/embeddings/create-embedding`, {
|
|
565
|
-
data: {
|
|
566
|
-
title: title.trim(),
|
|
567
|
-
content: content.trim(),
|
|
568
|
-
collectionType: slug || collectionType,
|
|
569
|
-
fieldName,
|
|
570
|
-
metadata: generateMetadata()
|
|
571
|
-
}
|
|
572
|
-
});
|
|
544
|
+
const contentToEmbed = content.trim();
|
|
545
|
+
const shouldChunk = contentToEmbed.length > CHUNK_SIZE;
|
|
546
|
+
const chunks = shouldChunk ? Math.ceil(contentToEmbed.length / CHUNK_SIZE) : 1;
|
|
547
|
+
if (shouldChunk) {
|
|
548
|
+
console.log(`Creating chunked embedding: ${contentToEmbed.length} chars (~${chunks} parts)`);
|
|
549
|
+
}
|
|
550
|
+
const result = await post(`/${PLUGIN_ID}/embeddings/create-embedding`, {
|
|
551
|
+
data: {
|
|
552
|
+
title: title.trim(),
|
|
553
|
+
content: contentToEmbed,
|
|
554
|
+
collectionType: slug || collectionType,
|
|
555
|
+
fieldName,
|
|
556
|
+
metadata: generateMetadata(),
|
|
557
|
+
autoChunk: shouldChunk
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
const responseData = result?.data || result;
|
|
561
|
+
if (responseData?.documentId) {
|
|
573
562
|
setExistingEmbedding({
|
|
574
|
-
documentId:
|
|
575
|
-
title:
|
|
576
|
-
content:
|
|
577
|
-
});
|
|
578
|
-
setIsVisible(false);
|
|
579
|
-
toggleNotification({
|
|
580
|
-
type: "success",
|
|
581
|
-
message: "Embedding created successfully"
|
|
563
|
+
documentId: responseData.documentId,
|
|
564
|
+
title: responseData.title,
|
|
565
|
+
content: responseData.content
|
|
582
566
|
});
|
|
583
567
|
}
|
|
568
|
+
setIsVisible(false);
|
|
569
|
+
const message = shouldChunk ? `Embedding created and chunked into ${chunks} parts` : "Embedding created successfully";
|
|
570
|
+
toggleNotification({ type: "success", message });
|
|
584
571
|
} catch (error) {
|
|
585
|
-
console.error("Failed to
|
|
572
|
+
console.error("Failed to create embedding:", error);
|
|
586
573
|
toggleNotification({
|
|
587
574
|
type: "danger",
|
|
588
|
-
message: error.message || "Failed to
|
|
575
|
+
message: error.message || "Failed to create embedding"
|
|
589
576
|
});
|
|
590
577
|
} finally {
|
|
591
578
|
setIsLoading(false);
|
|
@@ -602,17 +589,9 @@ function EmbeddingsModal() {
|
|
|
602
589
|
if (isCheckingExisting) {
|
|
603
590
|
return /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Loader, { small: true, children: "Checking embeddings..." }) });
|
|
604
591
|
}
|
|
605
|
-
|
|
606
|
-
if (isUpdateMode) {
|
|
607
|
-
submitButtonText = isLoading ? "Updating..." : "Update Embedding";
|
|
608
|
-
} else {
|
|
609
|
-
submitButtonText = isLoading ? "Creating..." : "Create Embedding";
|
|
610
|
-
}
|
|
592
|
+
const submitButtonText = isLoading ? "Creating..." : "Create Embedding";
|
|
611
593
|
return /* @__PURE__ */ jsxs(Box, { paddingTop: 2, children: [
|
|
612
|
-
existingEmbedding ? /* @__PURE__ */
|
|
613
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleViewEmbedding, startIcon: /* @__PURE__ */ jsx(Eye, {}), fullWidth: true, children: "View Embedding" }),
|
|
614
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleOpenUpdate, startIcon: /* @__PURE__ */ jsx(Pencil, {}), variant: "secondary", fullWidth: true, children: "Update Embedding" })
|
|
615
|
-
] }) : /* @__PURE__ */ jsx(
|
|
594
|
+
existingEmbedding ? /* @__PURE__ */ jsx(Button, { onClick: handleViewEmbedding, startIcon: /* @__PURE__ */ jsx(Eye, {}), fullWidth: true, children: "View Embedding" }) : /* @__PURE__ */ jsx(
|
|
616
595
|
Button,
|
|
617
596
|
{
|
|
618
597
|
onClick: handleOpenCreate,
|
|
@@ -624,7 +603,7 @@ function EmbeddingsModal() {
|
|
|
624
603
|
),
|
|
625
604
|
!isSaved && !existingEmbedding && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { display: "block", marginTop: "0.5rem" }, children: "Save content first to create embedding" }),
|
|
626
605
|
/* @__PURE__ */ jsx(Modal.Root, { open: isVisible, onOpenChange: setIsVisible, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
|
|
627
|
-
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children:
|
|
606
|
+
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: "Create Embedding from Content" }) }),
|
|
628
607
|
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
629
608
|
/* @__PURE__ */ jsxs(StyledTypography, { variant: "omega", textColor: "neutral600", children: [
|
|
630
609
|
"Content: ",
|
|
@@ -650,10 +629,7 @@ function EmbeddingsModal() {
|
|
|
650
629
|
/* @__PURE__ */ jsxs(Box, { marginBottom: 4, children: [
|
|
651
630
|
/* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
652
631
|
/* @__PURE__ */ jsx(Field.Label, { children: "Content" }),
|
|
653
|
-
/* @__PURE__ */
|
|
654
|
-
fieldName ? `From field: ${fieldName}` : "Enter content manually",
|
|
655
|
-
isUpdateMode && " - Changes will regenerate the embedding vector"
|
|
656
|
-
] })
|
|
632
|
+
/* @__PURE__ */ jsx(Field.Hint, { children: fieldName ? `From field: ${fieldName}` : "Enter content manually" })
|
|
657
633
|
] }),
|
|
658
634
|
/* @__PURE__ */ jsx(
|
|
659
635
|
MarkdownEditor,
|
|
@@ -693,7 +669,7 @@ const index = {
|
|
|
693
669
|
defaultMessage: PLUGIN_ID
|
|
694
670
|
},
|
|
695
671
|
Component: async () => {
|
|
696
|
-
const { App } = await import("./App-
|
|
672
|
+
const { App } = await import("./App-C5NFY1UT.mjs");
|
|
697
673
|
return App;
|
|
698
674
|
}
|
|
699
675
|
});
|
|
@@ -736,4 +712,3 @@ export {
|
|
|
736
712
|
RobotIcon as R,
|
|
737
713
|
index as i
|
|
738
714
|
};
|
|
739
|
-
//# sourceMappingURL=index-B3j0IFUi.mjs.map
|
|
@@ -432,14 +432,13 @@ const StyledTypography = styled__default.default(designSystem.Typography)`
|
|
|
432
432
|
`;
|
|
433
433
|
const CHUNK_SIZE = 4e3;
|
|
434
434
|
function EmbeddingsModal() {
|
|
435
|
-
const { post, get
|
|
435
|
+
const { post, get } = admin.useFetchClient();
|
|
436
436
|
const { toggleNotification } = admin.useNotification();
|
|
437
437
|
const navigate = reactRouterDom.useNavigate();
|
|
438
438
|
const context = admin.unstable_useContentManagerContext();
|
|
439
439
|
const { form, id, slug, collectionType } = context;
|
|
440
440
|
const modifiedValues = form?.values || {};
|
|
441
441
|
const [isVisible, setIsVisible] = react.useState(false);
|
|
442
|
-
const [isUpdateMode, setIsUpdateMode] = react.useState(false);
|
|
443
442
|
const [title, setTitle] = react.useState("");
|
|
444
443
|
const [content, setContent] = react.useState("");
|
|
445
444
|
const [fieldName, setFieldName] = react.useState("");
|
|
@@ -455,18 +454,16 @@ function EmbeddingsModal() {
|
|
|
455
454
|
try {
|
|
456
455
|
const query = qs__default.default.stringify({
|
|
457
456
|
filters: {
|
|
458
|
-
$
|
|
459
|
-
{ collectionType: { $eq: slug } },
|
|
460
|
-
{ metadata: { $containsi: id } }
|
|
461
|
-
]
|
|
457
|
+
metadata: { $containsi: id }
|
|
462
458
|
}
|
|
463
459
|
});
|
|
464
460
|
const response = await get(`/${PLUGIN_ID}/embeddings/find?${query}`);
|
|
465
|
-
|
|
461
|
+
const embeddings = response.data?.data || response.data || [];
|
|
462
|
+
if (Array.isArray(embeddings) && embeddings.length > 0) {
|
|
466
463
|
setExistingEmbedding({
|
|
467
|
-
documentId:
|
|
468
|
-
title:
|
|
469
|
-
content:
|
|
464
|
+
documentId: embeddings[0].documentId,
|
|
465
|
+
title: embeddings[0].title,
|
|
466
|
+
content: embeddings[0].content
|
|
470
467
|
});
|
|
471
468
|
}
|
|
472
469
|
} catch (error) {
|
|
@@ -477,16 +474,15 @@ function EmbeddingsModal() {
|
|
|
477
474
|
}
|
|
478
475
|
checkExistingEmbedding();
|
|
479
476
|
}, [id, slug, get]);
|
|
480
|
-
react.
|
|
481
|
-
if (!modifiedValues) return;
|
|
477
|
+
const extractContentFromForm = react.useCallback(() => {
|
|
478
|
+
if (!modifiedValues) return "";
|
|
482
479
|
const textFieldNames = ["content", "description", "body", "text", "richtext", "markdown"];
|
|
483
|
-
for (const
|
|
484
|
-
const value = modifiedValues[
|
|
480
|
+
for (const name of textFieldNames) {
|
|
481
|
+
const value = modifiedValues[name];
|
|
485
482
|
if (value) {
|
|
486
|
-
setFieldName(fieldName2);
|
|
487
483
|
if (typeof value === "string" && value.trim()) {
|
|
488
|
-
|
|
489
|
-
|
|
484
|
+
setFieldName(name);
|
|
485
|
+
return value;
|
|
490
486
|
} else if (Array.isArray(value)) {
|
|
491
487
|
const text = value.map((block) => {
|
|
492
488
|
if (block.children) {
|
|
@@ -495,13 +491,20 @@ function EmbeddingsModal() {
|
|
|
495
491
|
return "";
|
|
496
492
|
}).join("\n\n");
|
|
497
493
|
if (text.trim()) {
|
|
498
|
-
|
|
499
|
-
|
|
494
|
+
setFieldName(name);
|
|
495
|
+
return text;
|
|
500
496
|
}
|
|
501
497
|
}
|
|
502
498
|
}
|
|
503
499
|
}
|
|
500
|
+
return "";
|
|
504
501
|
}, [modifiedValues]);
|
|
502
|
+
react.useEffect(() => {
|
|
503
|
+
const formContent = extractContentFromForm();
|
|
504
|
+
if (formContent) {
|
|
505
|
+
setContent(formContent);
|
|
506
|
+
}
|
|
507
|
+
}, [extractContentFromForm]);
|
|
505
508
|
const contentLength = content.length;
|
|
506
509
|
const willChunk = contentLength > CHUNK_SIZE;
|
|
507
510
|
const estimatedChunks = willChunk ? Math.ceil(contentLength / (CHUNK_SIZE - 200)) : 1;
|
|
@@ -517,16 +520,12 @@ function EmbeddingsModal() {
|
|
|
517
520
|
}
|
|
518
521
|
const isValid = title.trim() && content.trim();
|
|
519
522
|
function handleOpenCreate() {
|
|
520
|
-
setIsUpdateMode(false);
|
|
521
523
|
setTitle("");
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (existingEmbedding) {
|
|
526
|
-
setIsUpdateMode(true);
|
|
527
|
-
setTitle(existingEmbedding.title);
|
|
528
|
-
setIsVisible(true);
|
|
524
|
+
const formContent = extractContentFromForm();
|
|
525
|
+
if (formContent) {
|
|
526
|
+
setContent(formContent);
|
|
529
527
|
}
|
|
528
|
+
setIsVisible(true);
|
|
530
529
|
}
|
|
531
530
|
async function handleSubmit(e) {
|
|
532
531
|
e.preventDefault();
|
|
@@ -546,50 +545,38 @@ function EmbeddingsModal() {
|
|
|
546
545
|
}
|
|
547
546
|
setIsLoading(true);
|
|
548
547
|
try {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
} else {
|
|
568
|
-
const result = await post(`/${PLUGIN_ID}/embeddings/create-embedding`, {
|
|
569
|
-
data: {
|
|
570
|
-
title: title.trim(),
|
|
571
|
-
content: content.trim(),
|
|
572
|
-
collectionType: slug || collectionType,
|
|
573
|
-
fieldName,
|
|
574
|
-
metadata: generateMetadata()
|
|
575
|
-
}
|
|
576
|
-
});
|
|
548
|
+
const contentToEmbed = content.trim();
|
|
549
|
+
const shouldChunk = contentToEmbed.length > CHUNK_SIZE;
|
|
550
|
+
const chunks = shouldChunk ? Math.ceil(contentToEmbed.length / CHUNK_SIZE) : 1;
|
|
551
|
+
if (shouldChunk) {
|
|
552
|
+
console.log(`Creating chunked embedding: ${contentToEmbed.length} chars (~${chunks} parts)`);
|
|
553
|
+
}
|
|
554
|
+
const result = await post(`/${PLUGIN_ID}/embeddings/create-embedding`, {
|
|
555
|
+
data: {
|
|
556
|
+
title: title.trim(),
|
|
557
|
+
content: contentToEmbed,
|
|
558
|
+
collectionType: slug || collectionType,
|
|
559
|
+
fieldName,
|
|
560
|
+
metadata: generateMetadata(),
|
|
561
|
+
autoChunk: shouldChunk
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
const responseData = result?.data || result;
|
|
565
|
+
if (responseData?.documentId) {
|
|
577
566
|
setExistingEmbedding({
|
|
578
|
-
documentId:
|
|
579
|
-
title:
|
|
580
|
-
content:
|
|
581
|
-
});
|
|
582
|
-
setIsVisible(false);
|
|
583
|
-
toggleNotification({
|
|
584
|
-
type: "success",
|
|
585
|
-
message: "Embedding created successfully"
|
|
567
|
+
documentId: responseData.documentId,
|
|
568
|
+
title: responseData.title,
|
|
569
|
+
content: responseData.content
|
|
586
570
|
});
|
|
587
571
|
}
|
|
572
|
+
setIsVisible(false);
|
|
573
|
+
const message = shouldChunk ? `Embedding created and chunked into ${chunks} parts` : "Embedding created successfully";
|
|
574
|
+
toggleNotification({ type: "success", message });
|
|
588
575
|
} catch (error) {
|
|
589
|
-
console.error("Failed to
|
|
576
|
+
console.error("Failed to create embedding:", error);
|
|
590
577
|
toggleNotification({
|
|
591
578
|
type: "danger",
|
|
592
|
-
message: error.message || "Failed to
|
|
579
|
+
message: error.message || "Failed to create embedding"
|
|
593
580
|
});
|
|
594
581
|
} finally {
|
|
595
582
|
setIsLoading(false);
|
|
@@ -606,17 +593,9 @@ function EmbeddingsModal() {
|
|
|
606
593
|
if (isCheckingExisting) {
|
|
607
594
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: "Checking embeddings..." }) });
|
|
608
595
|
}
|
|
609
|
-
|
|
610
|
-
if (isUpdateMode) {
|
|
611
|
-
submitButtonText = isLoading ? "Updating..." : "Update Embedding";
|
|
612
|
-
} else {
|
|
613
|
-
submitButtonText = isLoading ? "Creating..." : "Create Embedding";
|
|
614
|
-
}
|
|
596
|
+
const submitButtonText = isLoading ? "Creating..." : "Create Embedding";
|
|
615
597
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingTop: 2, children: [
|
|
616
|
-
existingEmbedding ? /* @__PURE__ */ jsxRuntime.
|
|
617
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleViewEmbedding, startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}), fullWidth: true, children: "View Embedding" }),
|
|
618
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleOpenUpdate, startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}), variant: "secondary", fullWidth: true, children: "Update Embedding" })
|
|
619
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
598
|
+
existingEmbedding ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleViewEmbedding, startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}), fullWidth: true, children: "View Embedding" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
620
599
|
designSystem.Button,
|
|
621
600
|
{
|
|
622
601
|
onClick: handleOpenCreate,
|
|
@@ -628,7 +607,7 @@ function EmbeddingsModal() {
|
|
|
628
607
|
),
|
|
629
608
|
!isSaved && !existingEmbedding && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { display: "block", marginTop: "0.5rem" }, children: "Save content first to create embedding" }),
|
|
630
609
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isVisible, onOpenChange: setIsVisible, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
|
631
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children:
|
|
610
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: "Create Embedding from Content" }) }),
|
|
632
611
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
|
|
633
612
|
/* @__PURE__ */ jsxRuntime.jsxs(StyledTypography, { variant: "omega", textColor: "neutral600", children: [
|
|
634
613
|
"Content: ",
|
|
@@ -654,10 +633,7 @@ function EmbeddingsModal() {
|
|
|
654
633
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { marginBottom: 4, children: [
|
|
655
634
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
|
|
656
635
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Content" }),
|
|
657
|
-
/* @__PURE__ */ jsxRuntime.
|
|
658
|
-
fieldName ? `From field: ${fieldName}` : "Enter content manually",
|
|
659
|
-
isUpdateMode && " - Changes will regenerate the embedding vector"
|
|
660
|
-
] })
|
|
636
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: fieldName ? `From field: ${fieldName}` : "Enter content manually" })
|
|
661
637
|
] }),
|
|
662
638
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
663
639
|
MarkdownEditor,
|
|
@@ -697,7 +673,7 @@ const index = {
|
|
|
697
673
|
defaultMessage: PLUGIN_ID
|
|
698
674
|
},
|
|
699
675
|
Component: async () => {
|
|
700
|
-
const { App } = await Promise.resolve().then(() => require("./App-
|
|
676
|
+
const { App } = await Promise.resolve().then(() => require("./App-CA5bQnKQ.js"));
|
|
701
677
|
return App;
|
|
702
678
|
}
|
|
703
679
|
});
|
|
@@ -738,4 +714,3 @@ exports.MarkdownEditor = MarkdownEditor;
|
|
|
738
714
|
exports.PLUGIN_ID = PLUGIN_ID;
|
|
739
715
|
exports.RobotIcon = RobotIcon;
|
|
740
716
|
exports.index = index;
|
|
741
|
-
//# sourceMappingURL=index-jf6vikTZ.js.map
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
|
@@ -8,5 +8,5 @@ interface Embedding {
|
|
|
8
8
|
interface EmbeddingsTableProps {
|
|
9
9
|
data: Embedding[];
|
|
10
10
|
}
|
|
11
|
-
export declare function EmbeddingsTable({ data }: EmbeddingsTableProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function EmbeddingsTable({ data }: Readonly<EmbeddingsTableProps>): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export {};
|