Skip to content

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 26 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
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 Apr 2, 2022
b686a3e
fix(events): typo
Sordie Apr 5, 2022
15a5c32
feat(serialization): add lex v2 event test
Sordie Apr 5, 2022
32ef80c
Merge branch 'master' into feat/lex-v2
Sordie Apr 5, 2022
228c0d0
Ensure at build time that the jni parts of the runtime-interface-clie…
bmoffatt Apr 7, 2022
af314fa
Update aws-lambda-java-runtime-interface-client.yml
bmoffatt Apr 9, 2022
6faf215
version bump aws-lambda-java-runtime-interface-client 2.1.0 -> 2.1.1
bmoffatt Apr 11, 2022
9e3fd0f
Update RELEASE.CHANGELOG.md
bmoffatt Apr 11, 2022
d5ccbbf
fix: typo
Sordie May 8, 2022
8bd5419
Update Curl to 7.83.0
SukanyaHanumanthu Apr 28, 2022
8b7c539
remove invalid link from README (#333)
bmoffatt Apr 29, 2022
65efb6f
Fix os compatibility tests by enabling multi-platform build and testi…
zsombor-balogh May 3, 2022
9d33d26
Use correct package name prefix of 'NativeClient' class (#335)
zsombor-balogh May 4, 2022
b047a4d
Fix os compatibility test local builds on arm64 hosts (#338)
zsombor-balogh May 6, 2022
38894c0
Merge branch 'events-v4-serialization-v2' into feat/lex-v2
Sordie May 14, 2022
2e2f7f4
feat(events): move lex v2 event test
Sordie May 14, 2022
315c14f
chore(events): revert merge failures
Sordie May 14, 2022
1566bd5
fix: mapping errors
Sordie May 15, 2022
7ff3c41
feat: add sentiment and kendra response
Sordie May 15, 2022
faba38a
feat(events): add kendra response to event
Sordie May 25, 2022
aa16e26
Merge branch 'events-v4-serialization-v2' into feat/lex-v2
Sordie Jun 3, 2022
529e8fc
fix(events): provide expected json for tests
Sordie Jul 3, 2022
3c87ab8
chore(events): add response test
Sordie Jul 3, 2022
313a893
Merge branch 'events-v4-serialization-v2' into feat/lex-v2
Sordie Jul 3, 2022
86a11cf
chore(events): remove cloneable interface and update year
Sordie Jul 9, 2022
15ebfcb
feat(events): keep slots with null value
Sordie Aug 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
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;
}
}
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;
}
}
Loading