@slicemachine/manager 0.24.4-alpha.xru-kong-obelix-services.1 → 0.24.4-alpha.xru-poc-ai.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,7 @@ const SLICE_MACHINE_USER_AGENT = require("../../constants/SLICE_MACHINE_USER_AGE
16
16
  const API_ENDPOINTS = require("../../constants/API_ENDPOINTS.cjs");
17
17
  const errors = require("../../errors.cjs");
18
18
  const BaseManager = require("../BaseManager.cjs");
19
+ const clientBedrockRuntime = require("@aws-sdk/client-bedrock-runtime");
19
20
  function _interopNamespaceDefault(e) {
20
21
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
21
22
  if (e) {
@@ -655,6 +656,683 @@ class SlicesManager extends BaseManager.BaseManager {
655
656
  }));
656
657
  return { errors: customTypeReadErrors };
657
658
  }
659
+ async generateSlice(args) {
660
+ var _a, _b, _c, _d, _e;
661
+ assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
662
+ const AWS_REGION = "us-east-1";
663
+ const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
664
+ const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
665
+ if (!AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY) {
666
+ throw new Error("AWS credentials are not set.");
667
+ }
668
+ const bedrockClient = new clientBedrockRuntime.BedrockRuntimeClient({
669
+ region: AWS_REGION,
670
+ credentials: {
671
+ accessKeyId: AWS_ACCESS_KEY_ID,
672
+ secretAccessKey: AWS_SECRET_ACCESS_KEY
673
+ }
674
+ });
675
+ const getSharedSliceSchema = () => {
676
+ return `
677
+
678
+ /**
679
+ * Represents a Prismic Slice.
680
+ * @property {string} type - Should always be "SharedSlice".
681
+ * @property {string} id - Unique identifier for the slice in snake_case.
682
+ * @property {string} name - Human-readable name in PascalCase.
683
+ * @property {string} description - Brief explanation of the slice's purpose.
684
+ * @property {SliceVariation[]} variations - Array of variations for the slice.
685
+ */
686
+ type PrismicSlice = {
687
+ type: "SharedSlice";
688
+ id: string;
689
+ name: string;
690
+ description: string;
691
+ variations: SliceVariation[];
692
+ };
693
+
694
+ /**
695
+ * Represents a variation of a Prismic Slice.
696
+ * @property {string} id - Unique identifier for the variation in snake_case.
697
+ * @property {string} name - Human-readable name in PascalCase.
698
+ * @property {string} description - Brief explanation of the variation's purpose.
699
+ * @property {string} docURL - Legacy property, required with an empty string.
700
+ * @property {string} version - Legacy property, required with the name property value.
701
+ * @property {Record<string, PrismicField>} [primary] - Primary fields defining the main content of the slice.
702
+ */
703
+ type SliceVariation = {
704
+ id: string;
705
+ name: string;
706
+ description: string;
707
+ primary: Record<string, PrismicField>;
708
+ docURL: string;
709
+ version: string;
710
+ };
711
+
712
+ /**
713
+ * Union type representing all possible Prismic fields.
714
+ */
715
+ type PrismicField =
716
+ | UIDField
717
+ | BooleanField
718
+ | ColorField
719
+ | DateField
720
+ | TimestampField
721
+ | NumberField
722
+ | KeyTextField
723
+ | SelectField
724
+ | StructuredTextField
725
+ | ImageField
726
+ | LinkField
727
+ | GeoPointField
728
+ | EmbedField
729
+ | GroupField;
730
+
731
+ /**
732
+ * Represents a UID Field in Prismic.
733
+ * @property {"UID"} type - Field type.
734
+ * @property {Object} config - Configuration object.
735
+ * @property {string} config.label - Label displayed in the editor.
736
+ * @property {string} [config.placeholder] - Placeholder text.
737
+ * @property {string} [config.customregex] - Custom regex for validation.
738
+ * @property {string} [config.errorMessage] - Error message for invalid input.
739
+ */
740
+ type UIDField = {
741
+ type: "UID";
742
+ config: {
743
+ label: string;
744
+ placeholder?: string;
745
+ customregex?: string;
746
+ errorMessage?: string;
747
+ };
748
+ };
749
+
750
+ /**
751
+ * Represents a Boolean Field in Prismic.
752
+ * @property {"Boolean"} type - Field type.
753
+ * @property {Object} config - Configuration object.
754
+ * @property {string} config.label - Label displayed in the editor.
755
+ * @property {boolean} [config.default_value] - Default value (true or false).
756
+ */
757
+ type BooleanField = {
758
+ type: "Boolean";
759
+ config: {
760
+ label: string;
761
+ default_value?: boolean;
762
+ };
763
+ };
764
+
765
+ /**
766
+ * Represents a Color Field in Prismic.
767
+ * @property {"Color"} type - Field type.
768
+ * @property {Object} config - Configuration object.
769
+ * @property {string} config.label - Label displayed in the editor.
770
+ */
771
+ type ColorField = {
772
+ type: "Color";
773
+ config: {
774
+ label: string;
775
+ };
776
+ };
777
+
778
+ /**
779
+ * Represents a Date Field in Prismic.
780
+ * @property {"Date"} type - Field type.
781
+ * @property {Object} config - Configuration object.
782
+ * @property {string} config.label - Label displayed in the editor.
783
+ */
784
+ type DateField = {
785
+ type: "Date";
786
+ config: {
787
+ label: string;
788
+ };
789
+ };
790
+
791
+ /**
792
+ * Represents a Timestamp Field in Prismic.
793
+ * @property {"Timestamp"} type - Field type.
794
+ * @property {Object} config - Configuration object.
795
+ * @property {string} config.label - Label displayed in the editor.
796
+ */
797
+ type TimestampField = {
798
+ type: "Timestamp";
799
+ config: {
800
+ label: string;
801
+ };
802
+ };
803
+
804
+ /**
805
+ * Represents a Number Field in Prismic.
806
+ * @property {"Number"} type - Field type.
807
+ * @property {Object} config - Configuration object.
808
+ * @property {string} config.label - Label displayed in the editor.
809
+ * @property {string} [config.placeholder] - Placeholder text.
810
+ * @property {number} [config.min] - Minimum allowable value.
811
+ * @property {number} [config.max] - Maximum allowable value.
812
+ */
813
+ type NumberField = {
814
+ type: "Number";
815
+ config: {
816
+ label: string;
817
+ placeholder?: string;
818
+ min?: number;
819
+ max?: number;
820
+ };
821
+ };
822
+
823
+ /**
824
+ * Represents a Key Text Field in Prismic.
825
+ * @property {"Text"} type - Field type.
826
+ * @property {Object} config - Configuration object.
827
+ * @property {string} config.label - Label displayed in the editor.
828
+ * @property {string} [config.placeholder] - Placeholder text.
829
+ */
830
+ type KeyTextField = {
831
+ type: "Text";
832
+ config: {
833
+ label: string;
834
+ placeholder?: string;
835
+ };
836
+ };
837
+
838
+ /**
839
+ * Represents a Select Field in Prismic.
840
+ * @property {"Select"} type - Field type.
841
+ * @property {Object} config - Configuration object.
842
+ * @property {string} config.label - Label displayed in the editor.
843
+ * @property {string[]} config.options - Array of options for the select dropdown.
844
+ */
845
+ type SelectField = {
846
+ type: "Select";
847
+ config: {
848
+ label: string;
849
+ options: string[];
850
+ };
851
+ };
852
+
853
+ /**
854
+ * Represents a Structured Text Field in Prismic.
855
+ * @property {"StructuredText"} type - Field type.
856
+ * @property {Object} config - Configuration object.
857
+ * @property {string} config.label - Label displayed in the editor.
858
+ * @property {string} [config.placeholder] - Placeholder text.
859
+ * @property {string} [config.single] - A comma-separated list of formatting options that does not allow line breaks. Options: paragraph | preformatted | heading1 | heading2 | heading3 | heading4 | heading5 | heading6 | strong | em | hyperlink | image | embed | list-item | o-list-item | rtl.
860
+ * @property {string} [config.multi] - A comma-separated list of formatting options, with paragraph breaks allowed. Options: paragraph | preformatted | heading1 | heading2 | heading3 | heading4 | heading5 | heading6 | strong | em | hyperlink | image | embed | list-item | o-list-item | rtl.
861
+ * @property {boolean} [config.allowTargetBlank] - Allows links to open in a new tab.
862
+ * @property {string[]} [config.labels] - An array of strings to define labels for custom formatting.
863
+ * @property {ImageConstraint} [config.imageConstraint] - Constraints for images within the rich text field.
864
+ */
865
+ type StructuredTextField = {
866
+ type: "StructuredText";
867
+ config: {
868
+ label: string;
869
+ placeholder?: string;
870
+ single?: string;
871
+ multi?: string;
872
+ allowTargetBlank?: boolean;
873
+ labels?: string[];
874
+ imageConstraint?: ImageConstraint;
875
+ };
876
+ };
877
+
878
+ /**
879
+ * Represents constraints for images within a rich text field.
880
+ * @property {number} [width] - Width constraint in pixels.
881
+ * @property {number
882
+ * @property {number} [height] - Height constraint in pixels.
883
+ */
884
+ type ImageConstraint = {
885
+ width?: number;
886
+ height?: number;
887
+ };
888
+
889
+ /**
890
+ * Represents an Image Field in Prismic.
891
+ * @property {"Image"} type - Field type.
892
+ * @property {Object} config - Configuration object.
893
+ * @property {string} config.label - Label displayed in the editor.
894
+ * @property {Object} [config.constraint] - Constraints for the image dimensions.
895
+ * @property {number} [config.constraint.width] - Width constraint.
896
+ * @property {number} [config.constraint.height] - Height constraint.
897
+ * @property {Thumbnail[]} [config.thumbnails] - Array of thumbnail configurations.
898
+ */
899
+ type ImageField = {
900
+ type: "Image";
901
+ config: {
902
+ label: string;
903
+ constraint?: {
904
+ width?: number;
905
+ height?: number;
906
+ };
907
+ thumbnails?: Thumbnail[];
908
+ };
909
+ };
910
+
911
+ /**
912
+ * Represents a Thumbnail configuration for an Image field.
913
+ * @property {string} name - Name of the thumbnail.
914
+ * @property {number} [width] - Width of the thumbnail in pixels.
915
+ * @property {number} [height] - Height of the thumbnail in pixels.
916
+ */
917
+ type Thumbnail = {
918
+ name: string;
919
+ width?: number;
920
+ height?: number;
921
+ };
922
+
923
+ /**
924
+ * Represents a Link Field in Prismic.
925
+ * @property {"Link"} type - Field type.
926
+ * @property {Object} config - Configuration object.
927
+ * @property {string} config.label - Label displayed in the editor.
928
+ * @property {"web" | "document" | "media"} config.select - Defines the type of link allowed.
929
+ * @property {string[]} [config.customtypes] - Defines which Prismic document types are allowed if select is "document".
930
+ */
931
+ type LinkField = {
932
+ type: "Link";
933
+ config: {
934
+ label: string;
935
+ select: "web" | "document" | "media";
936
+ customtypes?: string[];
937
+ allowText: boolean;
938
+ };
939
+ };
940
+
941
+ /**
942
+ * Represents an Embed Field in Prismic.
943
+ * @property {"Embed"} type - Field type.
944
+ * @property {Object} config - Configuration object.
945
+ * @property {string} config.label - Label displayed in the editor.
946
+ */
947
+ type EmbedField = {
948
+ type: "Embed";
949
+ config: {
950
+ label: string;
951
+ };
952
+ };
953
+
954
+ /**
955
+ * Represents a GeoPoint Field in Prismic.
956
+ * @property {"GeoPoint"} type - Field type.
957
+ * @property {Object} config - Configuration object.
958
+ * @property {string} config.label - Label displayed in the editor.
959
+ */
960
+ type GeoPointField = {
961
+ type: "GeoPoint";
962
+ config: {
963
+ label: string;
964
+ };
965
+ };
966
+
967
+ /**
968
+ * Represents a Group Field (Repeatable Fields) in Prismic.
969
+ * @property {"Group"} type - Field type.
970
+ * @property {Object} config - Configuration object.
971
+ * @property {string} config.label - Label displayed in the editor.
972
+ * @property {Record<string, PrismicField>} config.fields - Defines the fields inside the group.
973
+ */
974
+ type GroupField = {
975
+ type: "Group";
976
+ config: {
977
+ label: string;
978
+ fields: Record<string, PrismicField>;
979
+ };
980
+ };
981
+ `;
982
+ };
983
+ const buildSystemMessage = (schema, existingSlice) => {
984
+ return `
985
+ You are a world-class expert in creating Prismic Custom Type models for slices.
986
+ Your task is to generate a valid Prismic JSON model based solely on the provided description and the TypeScript schema below.
987
+ The JSON model must adhere strictly to these rules:
988
+ 1. Include all necessary fields as described.
989
+ 2. Use the "primary" object for all main content fields.
990
+ 3. Do NOT use an "items" field. If a field represents a collection, it must be defined inside a Group field within the "primary" object.
991
+ 4. Ensure that each field has appropriate placeholders, labels, and configurations.
992
+ 5. If the existing slices contain fields, ensure to understand the user prompt to update the existing slice instead of creating something from scratch.
993
+ 6. If you detect the user wants to add a variation, always ensure the new variation is not exactly the same as another existing one
994
+ 7. Always return the full valid slice, as given in existing it should be returned in a valid format.
995
+ 8. If you detect the user prompt is about creating a totally different slice, do it and discard what was given in the existing slice, BUT only if you detect if nothing related.
996
+ 9. NEVER generate a Link / Button text field, ONLY the Link / Button field itself is enough. So ONE field just for the Link / Button. ENABLE "allowText" when doing that.
997
+ 10. AND THE MOST ULTRA IMPORTANT THING! Output ONLY a valid JSON object without any additional commentary or formatting! ONLY JSON, I need to parse it after with JSON.parse!
998
+
999
+ ### TypeScript Schema for reference:
1000
+ ${schema}
1001
+
1002
+ ### Existing slice
1003
+ ${JSON.stringify(existingSlice)}
1004
+ `.trim();
1005
+ };
1006
+ const generatePrismicModel = async (userPrompt) => {
1007
+ var _a2, _b2, _c2, _d2, _e2;
1008
+ const schema = getSharedSliceSchema();
1009
+ const systemMessage = buildSystemMessage(schema, args.slice);
1010
+ const command = new clientBedrockRuntime.ConverseCommand({
1011
+ modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0",
1012
+ system: [
1013
+ {
1014
+ text: systemMessage + (args.imageFile ? `
1015
+ ### Additional important rules
1016
+ A. SUPER IMPORTANT, you have to check and read the image and generate the model according to what is visible.
1017
+ B. You MUST understand that background image are just a simple image field. Don't try to do anything fancy with it, just a simple image field.
1018
+ C. Even if the background image looks like two image, be smart and detect if it's actually just one simple background that don't need a GROUP!
1019
+ D. NEVER EVER ADD decorative elements as detailled fields
1020
+ ` : ``)
1021
+ }
1022
+ ],
1023
+ messages: [
1024
+ args.imageFile ? {
1025
+ role: "user",
1026
+ content: [
1027
+ {
1028
+ image: {
1029
+ format: "png",
1030
+ source: { bytes: args.imageFile }
1031
+ }
1032
+ }
1033
+ ]
1034
+ } : {
1035
+ role: "user",
1036
+ content: [
1037
+ {
1038
+ text: `Generate a valid Prismic JSON model based on the following description:
1039
+
1040
+ ${userPrompt}`
1041
+ }
1042
+ ]
1043
+ }
1044
+ ]
1045
+ });
1046
+ try {
1047
+ console.log("Before sending command");
1048
+ const response2 = await bedrockClient.send(command);
1049
+ console.log("After response", JSON.stringify(response2));
1050
+ const result = (_e2 = (_d2 = (_c2 = (_b2 = (_a2 = response2.output) == null ? void 0 : _a2.message) == null ? void 0 : _b2.content) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.text) == null ? void 0 : _e2.trim();
1051
+ console.log("After sending command");
1052
+ if (!result) {
1053
+ throw new Error("No valid response received.");
1054
+ }
1055
+ return result;
1056
+ } catch (error) {
1057
+ console.error("Error generating Prismic model:", error);
1058
+ throw error;
1059
+ }
1060
+ };
1061
+ const prismicModel = await generatePrismicModel(args.userPrompt);
1062
+ console.log("After saving slice", prismicModel);
1063
+ const newSlice = {
1064
+ ...args.slice,
1065
+ variations: JSON.parse(prismicModel).variations
1066
+ };
1067
+ const response = await this.updateSlice({
1068
+ libraryID: args.libraryID,
1069
+ model: newSlice
1070
+ });
1071
+ if (response.errors.length) {
1072
+ return {
1073
+ errors: response.errors
1074
+ };
1075
+ }
1076
+ try {
1077
+ if (args.imageFile) {
1078
+ await this.updateSliceScreenshot({
1079
+ libraryID: args.libraryID,
1080
+ sliceID: newSlice.id,
1081
+ variationID: newSlice.variations[0].id,
1082
+ data: args.imageFile
1083
+ });
1084
+ const extMocks = mockSlice.mockSlice({ model: newSlice });
1085
+ console.log("extMocks", extMocks);
1086
+ const command = new clientBedrockRuntime.ConverseCommand({
1087
+ modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0",
1088
+ system: [
1089
+ {
1090
+ text: `
1091
+ # Task 1
1092
+ You are a world-class expert in creating Prismic Mocks for slices.
1093
+ Your task is to generate a valid Prismic JSON mocks based solely on the provided existing mocks.
1094
+ The goal is for you to take the image from the user input, detect the text and fill ensure the existing mock data is aligned with what is visible.
1095
+ Don't handle images.
1096
+ Only handle text.
1097
+ If you see a repetition with a group, you must create the same number of group items that are visible on the image.
1098
+ KEEP THE EXACT SAME STRUCTURE FOR THE MOCKS DATA, ONLY FILL IN THE TEXT FIELDS!
1099
+ AND ULTRA IMPORTANT! Output ONLY a valid JSON object without any additional commentary or formatting! ONLY JSON with the same existing mock format, I need to parse it after with JSON.parse!
1100
+
1101
+ ### Existing mocks
1102
+ ${JSON.stringify(extMocks)}
1103
+
1104
+ THAT was your FIRST task!
1105
+ # Task 2
1106
+
1107
+ Now you also have a second task, generating the slice code!
1108
+ Generate fully isolated slice mock that don't require any package. The code is in React.
1109
+ You have to ensure the mocks data will be the input of your code.
1110
+ Use the example of a slice fully isolated from bellow to help you know how to code a slice. But use the mocks data as input and the slice name etc.
1111
+ NEVER USE <style jsx> in the final code, just <style> is enough! It's important to not use <style jsx>!
1112
+ Ensure that the color used for the background is the same as the image provide in the user prompt! It's better no background color than a wrong one.
1113
+ Your goal is to make the code visually looks as close as possible to the image from the user input.
1114
+ AND ULTRA IMPORTANT! Output ONLY a valid React code without any additional commentary or formatting! Give me the code so I can just copy paste it into a React component file.
1115
+
1116
+ ### Tips
1117
+ For links just use PrismicNextLink just pass the field, PrismicNextLink will handle the display of the link text.
1118
+ DO NOT TRY TO MANUALLY GO INSIDE THE LINK TO WRITE THE TEXT IT"S DONE AUTOMATICALLY.
1119
+
1120
+ ### Example of a slice fully isolated
1121
+ import { type Content } from "@prismicio/client";
1122
+ import { PrismicNextLink, PrismicNextImage } from "@prismicio/next";
1123
+ import { SliceComponentProps, PrismicRichText } from "@prismicio/react";
1124
+
1125
+ export type HeroProps = SliceComponentProps<Content.HeroSlice>;
1126
+
1127
+ const Hero = ({ slice }: HeroProps): JSX.Element => {
1128
+ return (
1129
+ <section
1130
+ data-slice-type={slice.slice_type}
1131
+ data-slice-variation={slice.variation}
1132
+ className="es-bounded es-fullpage-hero"
1133
+ >
1134
+ <div
1135
+ className="es-fullpage-hero__content"
1136
+ >
1137
+ <div>
1138
+ <PrismicNextImage
1139
+ field={slice.primary.image}
1140
+ className="es-fullpage-hero__image"
1141
+ />
1142
+ </div>
1143
+
1144
+ <div className="es-fullpage-hero__content-right">
1145
+ <div className="es-fullpage-hero__content__intro">
1146
+ <p className="es-fullpage-hero__content__intro__eyebrow">
1147
+ {slice.primary.eyebrowHeadline}
1148
+ </p>
1149
+
1150
+ <div className="es-fullpage-hero__content__intro__headline">
1151
+ <PrismicRichText field={slice.primary.title} />
1152
+ </div>
1153
+
1154
+
1155
+ <div className="es-fullpage-hero__content__intro__description">
1156
+ <PrismicRichText field={slice.primary.description} />
1157
+ </div>
1158
+
1159
+ <PrismicNextLink
1160
+ className="es-call-to-action__link"
1161
+ field={slice.primary.callToActionLink}
1162
+ />
1163
+ </div>
1164
+ </div>
1165
+ </div>
1166
+ <style>
1167
+ {\`
1168
+ .es-bounded {
1169
+ margin: 0px;
1170
+ min-width: 0px;
1171
+ position: relative;
1172
+ }
1173
+
1174
+ .es-fullpage-hero {
1175
+ font-family: system-ui, sans-serif;
1176
+ background-color: #fff;
1177
+ color: #333;
1178
+ }
1179
+
1180
+ .es-fullpage-hero__image {
1181
+ max-width: 100%;
1182
+ height: auto;
1183
+ align-self: center;
1184
+ }
1185
+
1186
+ .es-fullpage-hero__content {
1187
+ display: flex;
1188
+ flex-direction: column;
1189
+ gap: 2rem;
1190
+ }
1191
+
1192
+ .es-fullpage-hero__content-right {
1193
+ display: flex;
1194
+ flex-direction: column;
1195
+ justify-content: space-around;
1196
+ padding: 1.5rem;
1197
+ }
1198
+
1199
+ @media (min-width: 1080px) {
1200
+ .es-fullpage-hero__content {
1201
+ flex-direction: row;
1202
+ }
1203
+
1204
+ .es-fullpage-hero__content > div {
1205
+ width: 50%;
1206
+ }
1207
+ }
1208
+
1209
+ .es-fullpage-hero__content__intro {
1210
+ display: grid;
1211
+ gap: 1rem;
1212
+ }
1213
+
1214
+ .es-fullpage-hero__content__intro__eyebrow {
1215
+ color: #47C1AF;
1216
+ font-size: 1.15rem;
1217
+ font-weight: 500;
1218
+ margin: 0;
1219
+ }
1220
+
1221
+ .es-fullpage-hero__content__intro__headline {
1222
+ font-size: 1.625rem;
1223
+ font-weight: 700;
1224
+ }
1225
+
1226
+ .es-fullpage-hero__content__intro__headline * {
1227
+ margin: 0;
1228
+ }
1229
+
1230
+ @media (min-width: 640px) {
1231
+ .es-fullpage-hero__content__intro__headline {
1232
+ font-size: 2rem;
1233
+ }
1234
+ }
1235
+
1236
+ @media (min-width: 1024px) {
1237
+ .es-fullpage-hero__content__intro__headline {
1238
+ font-size: 2.5rem;
1239
+ }
1240
+ }
1241
+
1242
+ @media (min-width: 1200px) {
1243
+ .es-fullpage-hero__content__intro__headline {
1244
+ font-size: 2.75rem;
1245
+ }
1246
+ }
1247
+
1248
+ .es-fullpage-hero__content__intro__description {
1249
+ font-size: 1.15rem;
1250
+ max-width: 38rem;
1251
+ }
1252
+
1253
+ .es-fullpage-hero__content__intro__description > p {
1254
+ margin: 0;
1255
+ }
1256
+
1257
+ @media (min-width: 1200px) {
1258
+ .es-fullpage-hero__content__intro__description {
1259
+ font-size: 1.4rem;
1260
+ }
1261
+ }
1262
+
1263
+ .es-call-to-action__link {
1264
+ justify-self: flex-start;
1265
+ border-radius: 0.25rem;
1266
+ font-size: 0.875rem;
1267
+ line-height: 1.3;
1268
+ padding: 1rem 2.625rem;
1269
+ transition: background-color 100ms linear;
1270
+ background-color: #16745f;
1271
+ color: #fff;
1272
+ }
1273
+
1274
+ .es-call-to-action__link:hover {
1275
+ background-color: #0d5e4c;
1276
+ }
1277
+ \`}
1278
+ </style>
1279
+ </section>
1280
+ );
1281
+ };
1282
+
1283
+ export default Hero;
1284
+
1285
+
1286
+ # Final output of task 1 and 2
1287
+ Return the task 1 and 2 output in a an object:
1288
+ {
1289
+ task1: <JSON of task 1 for the mocks>,
1290
+ task2: <plain string of the slice code for task 2>
1291
+ }
1292
+ THIS IS THE MOST IMPORTANT THING, YOU NEED A VALID JSON, with task1 and task2 property. And the correct format for each of the two property.
1293
+ `
1294
+ }
1295
+ ],
1296
+ messages: [
1297
+ {
1298
+ role: "user",
1299
+ content: [
1300
+ {
1301
+ image: {
1302
+ format: "png",
1303
+ source: { bytes: args.imageFile }
1304
+ }
1305
+ }
1306
+ ]
1307
+ }
1308
+ ]
1309
+ });
1310
+ console.log("Before sending mock command");
1311
+ const response2 = await bedrockClient.send(command);
1312
+ console.log("After response", JSON.stringify(response2));
1313
+ const result = (_e = (_d = (_c = (_b = (_a = response2.output) == null ? void 0 : _a.message) == null ? void 0 : _b.content) == null ? void 0 : _c[0]) == null ? void 0 : _d.text) == null ? void 0 : _e.trim();
1314
+ console.log("After sending mock command");
1315
+ if (result) {
1316
+ await this.updateSliceMocks({
1317
+ libraryID: args.libraryID,
1318
+ sliceID: newSlice.id,
1319
+ mocks: JSON.parse(result).task1
1320
+ });
1321
+ await this.sliceMachinePluginRunner.callHook("slice:update-code", {
1322
+ libraryID: args.libraryID,
1323
+ model: newSlice,
1324
+ componentContents: JSON.parse(result).task2
1325
+ });
1326
+ }
1327
+ }
1328
+ } catch (e) {
1329
+ console.log("Error", e);
1330
+ }
1331
+ return {
1332
+ errors: [],
1333
+ slice: newSlice
1334
+ };
1335
+ }
658
1336
  }
659
1337
  exports.SlicesManager = SlicesManager;
660
1338
  //# sourceMappingURL=SlicesManager.cjs.map