@aws-amplify/data-schema 1.25.1 → 1.25.3
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 +13 -7
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/ai/ConversationSchemaProcessor.js +28 -4
- package/dist/cjs/ai/ConversationSchemaProcessor.js.map +1 -1
- package/dist/esm/SchemaProcessor.mjs +13 -7
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/ai/ConversationSchemaProcessor.mjs +28 -4
- package/dist/esm/ai/ConversationSchemaProcessor.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/SchemaProcessor.ts +17 -7
- package/src/ai/ConversationSchemaProcessor.ts +37 -4
package/package.json
CHANGED
package/src/SchemaProcessor.ts
CHANGED
|
@@ -1821,13 +1821,23 @@ const schemaPreprocessor = (
|
|
|
1821
1821
|
const refersToString = typeDef.data.originalName
|
|
1822
1822
|
? ` @refersTo(name: "${typeDef.data.originalName}")`
|
|
1823
1823
|
: '';
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1824
|
+
|
|
1825
|
+
const disabledAttrs = modelAttributesFromDisabledOps(
|
|
1826
|
+
typeDef.data.disabledOperations,
|
|
1827
|
+
);
|
|
1828
|
+
const modelAttrs = disabledAttrs
|
|
1829
|
+
? `timestamps: null, ${disabledAttrs}`
|
|
1830
|
+
: 'timestamps: null';
|
|
1831
|
+
|
|
1832
|
+
/*
|
|
1833
|
+
* TODO: update @model(timestamps: null) once a longer term solution gets
|
|
1834
|
+
* determined.
|
|
1835
|
+
*
|
|
1836
|
+
* Context: SQL schema should not be automatically inserted with timestamp
|
|
1837
|
+
* fields, passing (timestamps: null) to @model to suppress this behavior
|
|
1838
|
+
* as a short term solution.
|
|
1839
|
+
*/
|
|
1840
|
+
const model = `type ${typeName} @model(${modelAttrs}) ${authString}${refersToString}\n{\n ${joined}\n}`;
|
|
1831
1841
|
gqlModels.push(model);
|
|
1832
1842
|
} else {
|
|
1833
1843
|
const fields = typeDef.data.fields as Record<string, BaseModelField>;
|
|
@@ -6,12 +6,14 @@ import type {
|
|
|
6
6
|
InternalConversationType,
|
|
7
7
|
DataToolDefinition,
|
|
8
8
|
} from './ConversationType';
|
|
9
|
+
import type { InferenceConfiguration } from './ModelType';
|
|
9
10
|
|
|
10
11
|
export const createConversationField = (
|
|
11
12
|
typeDef: InternalConversationType,
|
|
12
13
|
typeName: string,
|
|
13
14
|
): { field: string; functionHandler: LambdaFunctionDefinition } => {
|
|
14
|
-
const { aiModel, systemPrompt, handler, tools } =
|
|
15
|
+
const { aiModel, systemPrompt, inferenceConfiguration, handler, tools } =
|
|
16
|
+
typeDef;
|
|
15
17
|
const { strategy, provider } = extractAuthorization(typeDef, typeName);
|
|
16
18
|
|
|
17
19
|
const args: Record<string, string> = {
|
|
@@ -28,9 +30,21 @@ export const createConversationField = (
|
|
|
28
30
|
systemPrompt: systemPrompt.replace(/\r?\n/g, '\\n'),
|
|
29
31
|
};
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
// Add each arg with quotes (aiModel and systemPrompt)
|
|
34
|
+
const argsParts = [];
|
|
35
|
+
for (const [key, value] of Object.entries(args)) {
|
|
36
|
+
argsParts.push(`${key}: "${value}"`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Add inferenceConfiguration (do nothing if it doesn't exist or is empty)
|
|
40
|
+
const formattedInferenceConfig = formatInferenceConfig(
|
|
41
|
+
inferenceConfiguration,
|
|
42
|
+
);
|
|
43
|
+
if (formattedInferenceConfig) {
|
|
44
|
+
argsParts.push(`inferenceConfiguration: ${formattedInferenceConfig}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const argsString = argsParts.join(', ');
|
|
34
48
|
|
|
35
49
|
const authString = `, auth: { strategy: ${strategy}, provider: ${provider} }`;
|
|
36
50
|
const functionHandler: LambdaFunctionDefinition = {};
|
|
@@ -52,6 +66,25 @@ export const createConversationField = (
|
|
|
52
66
|
return { field, functionHandler };
|
|
53
67
|
};
|
|
54
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Format inferenceConfiguration as GraphQL input syntax.
|
|
71
|
+
* Returns null if config is undefined or has no valid properties.
|
|
72
|
+
*/
|
|
73
|
+
const formatInferenceConfig = (
|
|
74
|
+
config: InferenceConfiguration | undefined,
|
|
75
|
+
): string | null => {
|
|
76
|
+
if (!config) return null;
|
|
77
|
+
|
|
78
|
+
const parts: string[] = [];
|
|
79
|
+
if (config.temperature !== undefined)
|
|
80
|
+
parts.push(`temperature: ${config.temperature}`);
|
|
81
|
+
if (config.maxTokens !== undefined)
|
|
82
|
+
parts.push(`maxTokens: ${config.maxTokens}`);
|
|
83
|
+
if (config.topP !== undefined) parts.push(`topP: ${config.topP}`);
|
|
84
|
+
|
|
85
|
+
return parts.length > 0 ? `{ ${parts.join(', ')} }` : null;
|
|
86
|
+
};
|
|
87
|
+
|
|
55
88
|
const isRef = (query: unknown): query is { data: InternalRef['data'] } =>
|
|
56
89
|
(query as any)?.data?.type === 'ref';
|
|
57
90
|
|