@aws-amplify/data-schema 1.7.0 → 1.8.1
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/runtime/internals/ai/convertItemToConversation.js +5 -1
- package/dist/cjs/runtime/internals/ai/convertItemToConversation.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js +1 -1
- package/dist/cjs/runtime/internals/ai/createCreateConversationFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createDeleteConversationFunction.js +1 -1
- package/dist/cjs/runtime/internals/ai/createDeleteConversationFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js +1 -1
- package/dist/cjs/runtime/internals/ai/createGetConversationFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js +1 -1
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js +3 -1
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js.map +1 -1
- package/dist/esm/ai/ConversationType.d.ts +7 -2
- package/dist/esm/runtime/internals/ai/convertItemToConversation.d.ts +1 -1
- package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs +5 -1
- package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs +1 -1
- package/dist/esm/runtime/internals/ai/createCreateConversationFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createDeleteConversationFunction.mjs +1 -1
- package/dist/esm/runtime/internals/ai/createDeleteConversationFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs +1 -1
- package/dist/esm/runtime/internals/ai/createGetConversationFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs +1 -1
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs +3 -1
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/ai/ConversationType.ts +12 -3
- package/src/runtime/internals/ai/convertItemToConversation.ts +8 -0
- package/src/runtime/internals/ai/createCreateConversationFunction.ts +4 -0
- package/src/runtime/internals/ai/createDeleteConversationFunction.ts +4 -0
- package/src/runtime/internals/ai/createGetConversationFunction.ts +4 -0
- package/src/runtime/internals/ai/createListConversationsFunction.ts +4 -0
- package/src/runtime/internals/ai/createSendMessageFunction.ts +8 -1
package/package.json
CHANGED
|
@@ -56,7 +56,9 @@ export interface ConversationRoute {
|
|
|
56
56
|
*
|
|
57
57
|
* Deletes an existing {@link Conversation} based on ID.
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
delete: (
|
|
60
|
+
input: ConversationRouteDeleteInput,
|
|
61
|
+
) => SingularReturnValue<Conversation>;
|
|
60
62
|
/**
|
|
61
63
|
* @experimental
|
|
62
64
|
*
|
|
@@ -66,12 +68,14 @@ export interface ConversationRoute {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
// conversation types
|
|
69
|
-
interface
|
|
71
|
+
interface ConversationSendMessageInputObject {
|
|
70
72
|
content: ConversationSendMessageInputContent[];
|
|
71
73
|
aiContext?: string | Record<string, any>;
|
|
72
74
|
toolConfiguration?: ToolConfiguration;
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
export type ConversationSendMessageInput = ConversationSendMessageInputObject | string;
|
|
78
|
+
|
|
75
79
|
interface ConversationListMessagesInput {
|
|
76
80
|
limit?: number;
|
|
77
81
|
nextToken?: string | null;
|
|
@@ -81,13 +85,18 @@ type ConversationOnMessageHandler = (message: ConversationMessage) => void;
|
|
|
81
85
|
|
|
82
86
|
export interface Conversation {
|
|
83
87
|
id: string;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
updatedAt: string;
|
|
90
|
+
|
|
91
|
+
metadata?: Record<string, any>;
|
|
92
|
+
name?: string;
|
|
84
93
|
/**
|
|
85
94
|
* @experimental
|
|
86
95
|
*
|
|
87
96
|
* Sends a message to the current conversation.
|
|
88
97
|
*/
|
|
89
98
|
sendMessage: (
|
|
90
|
-
input: ConversationSendMessageInput,
|
|
99
|
+
input: ConversationSendMessageInput | string,
|
|
91
100
|
) => SingularReturnValue<ConversationMessage>;
|
|
92
101
|
/**
|
|
93
102
|
* @experimental
|
|
@@ -17,9 +17,13 @@ export const convertItemToConversation = (
|
|
|
17
17
|
client: BaseClient,
|
|
18
18
|
modelIntrospection: ModelIntrospectionSchema,
|
|
19
19
|
conversationId: string,
|
|
20
|
+
conversationCreatedAt: string,
|
|
21
|
+
conversationUpdatedAt: string,
|
|
20
22
|
conversationRouteName: string,
|
|
21
23
|
conversationMessageModel: SchemaModel,
|
|
22
24
|
getInternals: ClientInternalsGetter,
|
|
25
|
+
conversationMetadata?: Record<string, any>,
|
|
26
|
+
conversationName?: string,
|
|
23
27
|
): Conversation => {
|
|
24
28
|
if (!conversationId) {
|
|
25
29
|
throw new Error(
|
|
@@ -28,6 +32,10 @@ export const convertItemToConversation = (
|
|
|
28
32
|
}
|
|
29
33
|
return {
|
|
30
34
|
id: conversationId,
|
|
35
|
+
createdAt: conversationCreatedAt,
|
|
36
|
+
updatedAt: conversationUpdatedAt,
|
|
37
|
+
metadata: conversationMetadata,
|
|
38
|
+
name: conversationName,
|
|
31
39
|
onMessage: createOnMessageFunction(
|
|
32
40
|
client as BaseBrowserClient,
|
|
33
41
|
modelIntrospection,
|
|
@@ -41,9 +41,13 @@ export const createCreateConversationFunction =
|
|
|
41
41
|
client,
|
|
42
42
|
modelIntrospection,
|
|
43
43
|
data?.id,
|
|
44
|
+
data?.createdAt,
|
|
45
|
+
data?.updatedAt,
|
|
44
46
|
conversationRouteName,
|
|
45
47
|
conversationMessageModel,
|
|
46
48
|
getInternals,
|
|
49
|
+
data?.metadata,
|
|
50
|
+
data?.name,
|
|
47
51
|
),
|
|
48
52
|
errors,
|
|
49
53
|
};
|
|
@@ -44,9 +44,13 @@ export const createDeleteConversationFunction =
|
|
|
44
44
|
client,
|
|
45
45
|
modelIntrospection,
|
|
46
46
|
data?.id,
|
|
47
|
+
data?.createdAt,
|
|
48
|
+
data?.updatedAt,
|
|
47
49
|
conversationRouteName,
|
|
48
50
|
conversationMessageModel,
|
|
49
51
|
getInternals,
|
|
52
|
+
data?.metadata,
|
|
53
|
+
data?.name,
|
|
50
54
|
)
|
|
51
55
|
: data,
|
|
52
56
|
errors,
|
|
@@ -44,9 +44,13 @@ export const createGetConversationFunction =
|
|
|
44
44
|
client,
|
|
45
45
|
modelIntrospection,
|
|
46
46
|
data.id,
|
|
47
|
+
data.createdAt,
|
|
48
|
+
data.updatedAt,
|
|
47
49
|
conversationRouteName,
|
|
48
50
|
conversationMessageModel,
|
|
49
51
|
getInternals,
|
|
52
|
+
data?.metadata,
|
|
53
|
+
data?.name,
|
|
50
54
|
)
|
|
51
55
|
: data,
|
|
52
56
|
errors,
|
|
@@ -41,9 +41,13 @@ export const createListConversationsFunction =
|
|
|
41
41
|
client,
|
|
42
42
|
modelIntrospection,
|
|
43
43
|
datum.id,
|
|
44
|
+
datum.createdAt,
|
|
45
|
+
datum.updatedAt,
|
|
44
46
|
conversationRouteName,
|
|
45
47
|
conversationMessageModel,
|
|
46
48
|
getInternals,
|
|
49
|
+
datum?.metadata,
|
|
50
|
+
datum?.name,
|
|
47
51
|
);
|
|
48
52
|
}),
|
|
49
53
|
nextToken,
|
|
@@ -5,6 +5,7 @@ import { SingularReturnValue } from '../..';
|
|
|
5
5
|
import type {
|
|
6
6
|
Conversation,
|
|
7
7
|
ConversationMessage,
|
|
8
|
+
ConversationSendMessageInput,
|
|
8
9
|
} from '../../../ai/ConversationType';
|
|
9
10
|
import {
|
|
10
11
|
BaseClient,
|
|
@@ -31,13 +32,19 @@ export const createSendMessageFunction =
|
|
|
31
32
|
conversationRouteName: string,
|
|
32
33
|
getInternals: ClientInternalsGetter,
|
|
33
34
|
): Conversation['sendMessage'] =>
|
|
34
|
-
async (
|
|
35
|
+
async (input: ConversationSendMessageInput | string) => {
|
|
35
36
|
const { conversations } = modelIntrospection;
|
|
36
37
|
|
|
37
38
|
// Safe guard for standalone function. When called as part of client generation, this should never be falsy.
|
|
38
39
|
if (!conversations) {
|
|
39
40
|
return {} as SingularReturnValue<ConversationMessage>;
|
|
40
41
|
}
|
|
42
|
+
|
|
43
|
+
const processedInput: ConversationSendMessageInput =
|
|
44
|
+
typeof input === 'string' ? { content: [{ text: input }] } : input;
|
|
45
|
+
|
|
46
|
+
const { content, aiContext, toolConfiguration } = processedInput;
|
|
47
|
+
|
|
41
48
|
const sendSchema = conversations[conversationRouteName].message.send;
|
|
42
49
|
const sendOperation = customOpFactory(
|
|
43
50
|
client,
|