Skip to content

Commit

Permalink
Prompt Tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
docwho2 committed Dec 26, 2023
1 parent 780a09d commit c0249c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
12 changes: 6 additions & 6 deletions ChatGPT/src/main/java/cloud/cleo/squareup/ChatGPTLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public LexV2Response handleRequest(LexV2Event lexRequest, Context cntxt) {
}

private LexV2Response processGPT(LexV2EventWrapper lexRequest) {
final var input = lexRequest.getInputTranscript();
var input = lexRequest.getInputTranscript();
final var attrs = lexRequest.getSessionAttributes();
// Will be phone if from SMS, Facebook the Page Scoped userID, Chime unique generated ID
final var session_id = lexRequest.getSessionId();
Expand Down Expand Up @@ -164,8 +164,8 @@ private LexV2Response processGPT(LexV2EventWrapper lexRequest) {
return buildTerminatingResponse(lexRequest, "hangup_call", Map.of(), lexRequest.getLangString(GOODBYE));
} else {
attrs.put("blankCounter", count.toString());
// If we get slience (timeout without speech), then we get empty string on the transcript
return buildResponse(lexRequest, lexRequest.getLangString(BLANK_RESPONSE));
// set the input as "blank" so GPT knows caller said nothing and may need suggestions
input = "blank";
}
} else {
// The Input is not blank, so always put the counter back to zero
Expand Down Expand Up @@ -291,10 +291,10 @@ private LexV2Response processGPT(LexV2EventWrapper lexRequest) {

// Since we have a general response, add message asking if there is anything else
// For voice it just seems more natural to always end with a question.
if (lexRequest.isVoice() && !botResponse.endsWith("?")) {
//if (lexRequest.isVoice() && !botResponse.endsWith("?")) {
// If ends with question, then we don't need to further append question
botResponse = botResponse + lexRequest.getLangString(ANYTHING_ELSE);
}
//botResponse = botResponse + lexRequest.getLangString(ANYTHING_ELSE);
//}

if (session_new && lexRequest.isFacebook()) {
// If this a new Session send back a Welcome card for Facebook Channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public ChatGPTSessionState(LexV2EventWrapper lexRequest) {
switch (lexRequest.getChannelPlatform()) {
case FACEBOOK -> {
// Don't need very short or char limit, but we don't want to output a book either
sb.append("I am interacting via Facebook Messenger. Please keep answers short and concise. ");
sb.append("I am interacting via Facebook Messenger. Please keep answers concise. ");
}
case TWILIO -> {
// Try and keep SMS segements down, hence the "very" short reference and character preference
Expand All @@ -125,9 +125,16 @@ public ChatGPTSessionState(LexV2EventWrapper lexRequest) {
case SPEECH, DTMF -> {
sb.append("I am interacting with speech via a telephone interface. please keep answers short and concise. ");

// Blank input, meaning silienece timeout which is a speech only thing
sb.append("When the prompt is exactly blank, this means the caller did not say anything, so try and engage in conversation and also suggest ")
.append("queries the caller might be interested in (Hours,Location,Product Search,Language Chnage, etc.). ");

// Hangup
sb.append("When the caller indicates they are done with the conversation, execute the ").append(HANGUP_FUNCTION_NAME).append(" function. ");

// Always answer with a question to illicit the next repsonse, this makes the voice interaction more natural
sb.append("When responding always end the response with a question to illicit the next input since we are interacting via telephone. ");

// Speech Languages and switching between them at any time
sb.append("If the caller wants to interact in ")
.append(Arrays.stream(Language.values()).map(Language::toString).collect(Collectors.joining(" or ")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static Action getMainMenu() {
final var lexBotEN = StartBotConversationAction.builder()
.withDescription("ChatGPT English")
.withLocale(Locale.forLanguageTag("en-US"))
.withContent("You can ask about our products, hours, location, or speak to one of our team members. Tell us how we can help today?")
.withContent("Tell us how we can help today?")
.withSessionAttributesF(attributesFunction)
.build();
botLangMap.put(Language.English, lexBotEN);
Expand Down

0 comments on commit c0249c2

Please sign in to comment.