Skip to content

Commit

Permalink
udpate content shape, session to conversation, sender to role
Browse files Browse the repository at this point in the history
  • Loading branch information
atierian committed Aug 1, 2024
1 parent 3302042 commit c52a7f3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
\\"version\\": 1,
\\"models\\": {},
\\"enums\\": {
\\"ConversationMessageSender\\": {
\\"name\\": \\"ConversationMessageSender\\",
\\"ConversationParticipantRole\\": {
\\"name\\": \\"ConversationParticipantRole\\",
\\"values\\": [
\\"user\\",
\\"assistant\\"
Expand Down Expand Up @@ -54,7 +54,7 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
\\"association\\": {
\\"connectionType\\": \\"HAS_MANY\\",
\\"associatedWith\\": [
\\"sessionId\\"
\\"conversationId\\"
]
}
},
Expand Down Expand Up @@ -125,15 +125,15 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
\\"isRequired\\": true,
\\"attributes\\": []
},
\\"sessionId\\": {
\\"name\\": \\"sessionId\\",
\\"conversationId\\": {
\\"name\\": \\"conversationId\\",
\\"isArray\\": false,
\\"type\\": \\"ID\\",
\\"isRequired\\": true,
\\"attributes\\": []
},
\\"session\\": {
\\"name\\": \\"session\\",
\\"conversation\\": {
\\"name\\": \\"conversation\\",
\\"isArray\\": false,
\\"type\\": {
\\"model\\": \\"ConversationPirateChat\\"
Expand All @@ -143,23 +143,25 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
\\"association\\": {
\\"connectionType\\": \\"BELONGS_TO\\",
\\"targetNames\\": [
\\"sessionId\\"
\\"conversationId\\"
]
}
},
\\"sender\\": {
\\"name\\": \\"sender\\",
\\"role\\": {
\\"name\\": \\"role\\",
\\"isArray\\": false,
\\"type\\": {
\\"enum\\": \\"ConversationMessageSender\\"
\\"enum\\": \\"ConversationParticipantRole\\"
},
\\"isRequired\\": false,
\\"attributes\\": []
},
\\"content\\": {
\\"name\\": \\"content\\",
\\"isArray\\": false,
\\"type\\": \\"String\\",
\\"isArray\\": true,
\\"type\\": {
\\"nonModel\\": \\"ContentBlock\\"
},
\\"isRequired\\": false,
\\"attributes\\": []
},
Expand All @@ -181,7 +183,9 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
\\"assistantContent\\": {
\\"name\\": \\"assistantContent\\",
\\"isArray\\": false,
\\"type\\": \\"String\\",
\\"type\\": {
\\"nonModel\\": \\"ContentBlock\\"
},
\\"isRequired\\": false,
\\"attributes\\": []
},
Expand Down Expand Up @@ -243,8 +247,8 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
},
\\"nonModels\\": {},
\\"enums\\": {
\\"ConversationMessageSender\\": {
\\"name\\": \\"ConversationMessageSender\\",
\\"ConversationParticipantRole\\": {
\\"name\\": \\"ConversationParticipantRole\\",
\\"values\\": [
\\"user\\",
\\"assistant\\"
Expand All @@ -264,8 +268,8 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
},
\\"isRequired\\": false,
\\"arguments\\": {
\\"sessionId\\": {
\\"name\\": \\"sessionId\\",
\\"conversationId\\": {
\\"name\\": \\"conversationId\\",
\\"isArray\\": false,
\\"type\\": \\"ID\\",
\\"isRequired\\": false
Expand All @@ -286,8 +290,8 @@ exports[`Conversation Route Introspection Visitor Metadata snapshot should gener
\\"model\\": \\"ConversationMessagePirateChat\\"
},
\\"arguments\\": {
\\"sessionId\\": {
\\"name\\": \\"sessionId\\",
\\"conversationId\\": {
\\"name\\": \\"conversationId\\",
\\"isArray\\": false,
\\"isRequired\\": true,
\\"type\\": \\"ID\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ const getVisitor = (schema: string, settings: any = {}, directives: readonly Dir

describe('Conversation Route Introspection Visitor', () => {
const schema = /* GraphQL */ `
enum ConversationMessageSender {
enum ConversationParticipantRole {
user
assistant
}
interface ConversationMessage {
id: ID!
sessionId: ID!
sender: ConversationMessageSender
conversationId: ID!
role: ConversationParticipantRole
# TODO: Update to ContentBlock -- need the types
content: String
context: AWSJSON
uiComponents: [AWSJSON]
}
type Mutation {
pirateChat(sessionId: ID, content: String): ConversationMessage
# TODO: Update to ContentBlock -- need the types
pirateChat(conversationId: ID, content: String): ConversationMessage
@conversation(aiModel: "Claude3Haiku", functionName: "conversation-handler")
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export class AppSyncModelIntrospectionVisitor<
association: {
connectionType: CodeGenConnectionType.HAS_MANY,
associatedWith: [
'sessionId'
'conversationId'
]
}
},
Expand Down Expand Up @@ -365,15 +365,15 @@ export class AppSyncModelIntrospectionVisitor<
isRequired: true,
attributes: []
},
sessionId: {
name: 'sessionId',
conversationId: {
name: 'conversationId',
isArray: false,
type: 'ID',
isRequired: true,
attributes: []
},
session: {
name: 'session',
conversation: {
name: 'conversation',
isArray: false,
type: {
model: conversationModelName
Expand All @@ -383,23 +383,23 @@ export class AppSyncModelIntrospectionVisitor<
association: {
connectionType: CodeGenConnectionType.BELONGS_TO,
targetNames: [
'sessionId'
'conversationId'
]
}
},
sender: {
name: 'sender',
role: {
name: 'role',
isArray: false,
type: {
enum: 'ConversationMessageSender'
enum: 'ConversationParticipantRole'
},
isRequired: false,
attributes: []
},
content: {
name: 'content',
isArray: false,
type: 'String',
isArray: true,
type: { nonModel: 'ContentBlock' },
isRequired: false,
attributes: []
},
Expand All @@ -421,7 +421,7 @@ export class AppSyncModelIntrospectionVisitor<
assistantContent: {
name: 'assistantContent',
isArray: false,
type: 'String',
type: { nonModel: 'ContentBlock' },
isRequired: false,
attributes: []
},
Expand Down Expand Up @@ -489,8 +489,8 @@ export class AppSyncModelIntrospectionVisitor<
},
nonModels: {},
enums: {
ConversationMessageSender: {
name: 'ConversationMessageSender',
ConversationParticipantRole: {
name: 'ConversationParticipantRole',
values: ['user', 'assistant'],
}
},
Expand All @@ -506,8 +506,8 @@ export class AppSyncModelIntrospectionVisitor<
name: `onCreateAssistantResponse${routeName}`,
type: { model: `ConversationMessage${routeName}` },
arguments: {
'sessionId': {
name: 'sessionId',
'conversationId': {
name: 'conversationId',
isArray: false,
isRequired: true,
type: 'ID',
Expand Down

0 comments on commit c52a7f3

Please sign in to comment.