@aws-amplify/data-schema 1.9.0 → 1.9.2
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/cjs/SchemaProcessor.js +14 -2
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/ai/ConversationSchemaTypes.js +16 -8
- package/dist/cjs/ai/ConversationSchemaTypes.js.map +1 -1
- package/dist/esm/SchemaProcessor.mjs +14 -2
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/ai/ConversationSchemaTypes.d.ts +5 -1
- package/dist/esm/ai/ConversationSchemaTypes.mjs +16 -8
- package/dist/esm/ai/ConversationSchemaTypes.mjs.map +1 -1
- package/dist/esm/ai/ConversationType.d.ts +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/SchemaProcessor.ts +14 -2
- package/src/ai/ConversationSchemaTypes.ts +18 -8
- package/src/ai/ConversationType.ts +1 -1
|
@@ -300,13 +300,23 @@ function customOperationToGql(typeName, typeDef, authorization, isCustom = false
|
|
|
300
300
|
throw new Error(`Invalid Generation Route definition. A Generation Route must include a valid input. ${typeName} has an invalid or no input defined.`);
|
|
301
301
|
}
|
|
302
302
|
const { aiModel, systemPrompt, inferenceConfiguration } = typeDef.data.input;
|
|
303
|
+
// This is done to escape newlines in potentially multi-line system prompts
|
|
304
|
+
// e.g.
|
|
305
|
+
// generateStuff: a.generation({
|
|
306
|
+
// aiModel: a.ai.model('Claude 3 Haiku'),
|
|
307
|
+
// systemPrompt: `Generate a haiku
|
|
308
|
+
// make it multiline`,
|
|
309
|
+
// }),
|
|
310
|
+
//
|
|
311
|
+
// It doesn't affect non multi-line string inputs for system prompts
|
|
312
|
+
const escapedSystemPrompt = systemPrompt.replace(/\r?\n/g, '\\n');
|
|
303
313
|
const inferenceConfigurationEntries = Object.entries(inferenceConfiguration ?? {});
|
|
304
314
|
const inferenceConfigurationGql = inferenceConfigurationEntries.length > 0
|
|
305
315
|
? `, inferenceConfiguration: { ${inferenceConfigurationEntries
|
|
306
316
|
.map(([key, value]) => `${key}: ${value}`)
|
|
307
317
|
.join(', ')} }`
|
|
308
318
|
: '';
|
|
309
|
-
gqlHandlerContent += `@generation(aiModel: "${aiModel.resourcePath}", systemPrompt: "${
|
|
319
|
+
gqlHandlerContent += `@generation(aiModel: "${aiModel.resourcePath}", systemPrompt: "${escapedSystemPrompt}"${inferenceConfigurationGql}) `;
|
|
310
320
|
}
|
|
311
321
|
const gqlField = `${callSignature}: ${returnTypeName} ${gqlHandlerContent}${authString}`;
|
|
312
322
|
return {
|
|
@@ -907,7 +917,9 @@ const schemaPreprocessor = (schema) => {
|
|
|
907
917
|
}
|
|
908
918
|
else if (isConversationRoute(typeDef)) {
|
|
909
919
|
// TODO: add inferenceConfiguration values to directive.
|
|
910
|
-
|
|
920
|
+
const { field, functionHandler } = (0, ConversationSchemaTypes_1.createConversationField)(typeDef, typeName);
|
|
921
|
+
customMutations.push(field);
|
|
922
|
+
Object.assign(lambdaFunctions, functionHandler);
|
|
911
923
|
shouldAddConversationTypes = true;
|
|
912
924
|
}
|
|
913
925
|
}
|