@aws-amplify/data-schema 1.9.1 → 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 +3 -1
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/ai/ConversationSchemaTypes.js +6 -7
- package/dist/cjs/ai/ConversationSchemaTypes.js.map +1 -1
- package/dist/esm/SchemaProcessor.mjs +3 -1
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/ai/ConversationSchemaTypes.d.ts +5 -1
- package/dist/esm/ai/ConversationSchemaTypes.mjs +6 -7
- 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 +3 -1
- package/src/ai/ConversationSchemaTypes.ts +8 -7
- package/src/ai/ConversationType.ts +1 -1
package/package.json
CHANGED
package/src/SchemaProcessor.ts
CHANGED
|
@@ -1442,7 +1442,9 @@ const schemaPreprocessor = (
|
|
|
1442
1442
|
}
|
|
1443
1443
|
} else if (isConversationRoute(typeDef)) {
|
|
1444
1444
|
// TODO: add inferenceConfiguration values to directive.
|
|
1445
|
-
|
|
1445
|
+
const { field, functionHandler } = createConversationField(typeDef, typeName);
|
|
1446
|
+
customMutations.push(field);
|
|
1447
|
+
Object.assign(lambdaFunctions, functionHandler);
|
|
1446
1448
|
shouldAddConversationTypes = true;
|
|
1447
1449
|
}
|
|
1448
1450
|
} else if (staticSchema) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LambdaFunctionDefinition } from '@aws-amplify/data-schema-types';
|
|
1
2
|
import { InternalRef } from '../RefType';
|
|
2
3
|
import { capitalize } from '../runtime/utils';
|
|
3
4
|
import type {
|
|
@@ -8,7 +9,7 @@ import type {
|
|
|
8
9
|
export const createConversationField = (
|
|
9
10
|
typeDef: InternalConversationType,
|
|
10
11
|
typeName: string,
|
|
11
|
-
): string => {
|
|
12
|
+
): { field: string, functionHandler: LambdaFunctionDefinition } => {
|
|
12
13
|
const { aiModel, systemPrompt, handler, tools } = typeDef;
|
|
13
14
|
|
|
14
15
|
const args: Record<string, string> = {
|
|
@@ -25,12 +26,11 @@ export const createConversationField = (
|
|
|
25
26
|
systemPrompt: systemPrompt.replace(/\r?\n/g, '\\n'),
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
const functionHandler: LambdaFunctionDefinition = {};
|
|
28
30
|
if (handler) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
args['functionName'] = `Fn${capitalize(typeName)}`;
|
|
33
|
-
}
|
|
31
|
+
const functionName = `Fn${capitalize(typeName)}`;
|
|
32
|
+
args['functionName'] = functionName;
|
|
33
|
+
functionHandler[functionName] = handler;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const argsString = Object.entries(args)
|
|
@@ -43,7 +43,8 @@ export const createConversationField = (
|
|
|
43
43
|
|
|
44
44
|
const conversationDirective = `@conversation(${argsString}${toolsString})`;
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const field = `${typeName}(conversationId: ID!, content: [ContentBlockInput], aiContext: AWSJSON, toolConfiguration: ToolConfigurationInput): ConversationMessage ${conversationDirective} @aws_cognito_user_pools`;
|
|
47
|
+
return { field, functionHandler };
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
const isRef = (query: unknown): query is { data: InternalRef['data'] } =>
|
|
@@ -125,7 +125,7 @@ export interface ConversationInput {
|
|
|
125
125
|
systemPrompt: string;
|
|
126
126
|
inferenceConfiguration?: InferenceConfiguration;
|
|
127
127
|
tools?: ToolDefinition[];
|
|
128
|
-
handler?: DefineFunction
|
|
128
|
+
handler?: DefineFunction;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
export interface InternalConversationType
|