-
Notifications
You must be signed in to change notification settings - Fork 239
Adding Lex v2 event and response #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f158b72
feat(events): add lex v2 event and response
Sordie b686a3e
fix(events): typo
Sordie 15a5c32
feat(serialization): add lex v2 event test
Sordie 32ef80c
Merge branch 'master' into feat/lex-v2
Sordie 228c0d0
Ensure at build time that the jni parts of the runtime-interface-clie…
bmoffatt af314fa
Update aws-lambda-java-runtime-interface-client.yml
bmoffatt 6faf215
version bump aws-lambda-java-runtime-interface-client 2.1.0 -> 2.1.1
bmoffatt 9e3fd0f
Update RELEASE.CHANGELOG.md
bmoffatt d5ccbbf
fix: typo
Sordie 8bd5419
Update Curl to 7.83.0
SukanyaHanumanthu 8b7c539
remove invalid link from README (#333)
bmoffatt 65efb6f
Fix os compatibility tests by enabling multi-platform build and testi…
zsombor-balogh 9d33d26
Use correct package name prefix of 'NativeClient' class (#335)
zsombor-balogh b047a4d
Fix os compatibility test local builds on arm64 hosts (#338)
zsombor-balogh 38894c0
Merge branch 'events-v4-serialization-v2' into feat/lex-v2
Sordie 2e2f7f4
feat(events): move lex v2 event test
Sordie 315c14f
chore(events): revert merge failures
Sordie 1566bd5
fix: mapping errors
Sordie 7ff3c41
feat: add sentiment and kendra response
Sordie faba38a
feat(events): add kendra response to event
Sordie aa16e26
Merge branch 'events-v4-serialization-v2' into feat/lex-v2
Sordie 529e8fc
fix(events): provide expected json for tests
Sordie 3c87ab8
chore(events): add response test
Sordie 313a893
Merge branch 'events-v4-serialization-v2' into feat/lex-v2
Sordie 86a11cf
chore(events): remove cloneable interface and update year
Sordie 15ebfcb
feat(events): keep slots with null value
Sordie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
288 changes: 288 additions & 0 deletions
288
...da-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/LexV2Event.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,288 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
package com.amazonaws.services.lambda.runtime.events; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.util.Map; | ||
|
||
/** | ||
* Class to represent an Amazon Lex V2 event. | ||
* | ||
* @see <a href= | ||
* "https://docs.aws.amazon.com/lexv2/latest/dg/lambda.html#lambda-input-format">Using | ||
* an AWS Lambda function</a> | ||
*/ | ||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class LexV2Event implements Serializable, Cloneable { | ||
msailes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private String messageVersion; | ||
private String invocationSource; | ||
private String inputMode; | ||
private String responseContentType; | ||
private String sessionId; | ||
private String inputTranscript; | ||
private Bot bot; | ||
private Interpretation[] interpretations; | ||
private ProposedNextState proposedNextState; | ||
private Map<String, String> requestAttributes; | ||
private SessionState sessionState; | ||
private Transcription[] transcriptions; | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Bot implements Serializable, Cloneable { | ||
private String id; | ||
private String name; | ||
private String aliasId; | ||
private String aliasName; | ||
private String localeId; | ||
private String version; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Interpretation implements Serializable, Cloneable { | ||
private Intent intent; | ||
private Double nluConfidence; | ||
private SentimentResponse sentimentResponse; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Intent implements Serializable, Cloneable { | ||
private String confirmationState; | ||
private String name; | ||
private Map<String, Slot> slots; | ||
private String state; | ||
private KendraResponse kendraResponse; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Slot implements Serializable, Cloneable { | ||
private String shape; | ||
private SlotValue value; | ||
private Slot[] values; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class SlotValue implements Serializable, Cloneable { | ||
private String interpretedValue; | ||
private String originalValue; | ||
private String[] resolvedValues; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class KendraResponse implements Serializable, Cloneable { | ||
private String queryId; | ||
private KendraResponseResultItem[] resultItems; | ||
private Object[] facetResults; | ||
private Integer totalNumberOfResults; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class KendraResponseResultItem implements Serializable, Cloneable { | ||
private String id; | ||
private String type; | ||
private Object[] additionalAttributes; | ||
private String documentId; | ||
private KendraResponseDocumentInfo documentTitle; | ||
private KendraResponseDocumentInfo documentExcerpt; | ||
private String documentURI; | ||
private KendraResponseDocumentAttribute[] documentAttributes; | ||
private KendraResponseScoreAttributes scoreAttributes; | ||
private String feedbackToken; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class KendraResponseDocumentInfo implements Serializable, Cloneable { | ||
private String text; | ||
private KendraResponseDocumentHighlights[] highlights; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class KendraResponseDocumentHighlights implements Serializable, Cloneable { | ||
private Integer beginOffset; | ||
private Integer endOffset; | ||
private boolean topAnswer; | ||
private String type; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class KendraResponseDocumentAttribute implements Serializable, Cloneable { | ||
private String key; | ||
private Map<String, String> value; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class KendraResponseScoreAttributes implements Serializable, Cloneable { | ||
private String scoreConfidence; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class NluConfidence implements Serializable, Cloneable { | ||
private Double score; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class SentimentResponse implements Serializable, Cloneable { | ||
private String sentiment; | ||
private SentimentScore sentimentScore; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class SentimentScore implements Serializable, Cloneable { | ||
private Double mixed; | ||
private Double negative; | ||
private Double neutral; | ||
private Double positive; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class ProposedNextState implements Serializable, Cloneable { | ||
private DialogAction dialogAction; | ||
private Intent intent; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class DialogAction implements Serializable, Cloneable { | ||
private String slotToElicit; | ||
private String type; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class SessionState implements Serializable, Cloneable { | ||
private ActiveContext[] activeContexts; | ||
private Map<String, String> sessionAttributes; | ||
private RuntimeHints runtimeHints; | ||
private DialogAction dialogAction; | ||
private Intent intent; | ||
private String originatingRequestId; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class ActiveContext implements Serializable, Cloneable { | ||
private String name; | ||
private Map<String, String> contextAttributes; | ||
private TimeToLive timeToLive; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class TimeToLive implements Serializable, Cloneable { | ||
private Integer timeToLiveInSeconds; | ||
private Integer turnsToLive; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class RuntimeHints implements Serializable, Cloneable { | ||
private Map<String, Map<String, Hint>> slotHints; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Hint implements Serializable, Cloneable { | ||
private RuntimeHintValue[] runtimeHintValues; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class RuntimeHintValue implements Serializable, Cloneable { | ||
private String phrase; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Transcription implements Serializable, Cloneable { | ||
private String transcription; | ||
private Double transcriptionConfidence; | ||
private ResolvedContext resolvedContext; | ||
private Map<String, Slot> resolvedSlots; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class ResolvedContext implements Serializable, Cloneable { | ||
private String intent; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/LexV2Response.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
package com.amazonaws.services.lambda.runtime.events; | ||
|
||
import com.amazonaws.services.lambda.runtime.events.LexV2Event.SessionState; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.util.Map; | ||
|
||
/** | ||
* Class to represent an Amazon Lex V2 response. | ||
* | ||
* @see <a | ||
* href="https://docs.aws.amazon.com/lexv2/latest/dg/lambda.html#lambda-response-format">Using | ||
* an AWS Lambda function</a> | ||
*/ | ||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class LexV2Response implements Serializable, Cloneable { | ||
private SessionState sessionState; | ||
private Message[] messages; | ||
private Map<String, String> requestAttributes; | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Message implements Serializable, Cloneable { | ||
private String contentType; | ||
private String content; | ||
private ImageResponseCard imageResponseCard; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class ImageResponseCard implements Serializable, Cloneable { | ||
private String title; | ||
private String subtitle; | ||
private String imageUrl; | ||
private Button[] buttons; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Button implements Serializable, Cloneable { | ||
private String text; | ||
private String value; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.