Skip to content

Commit

Permalink
Merge pull request #229 from rwth-acis/rate_responses
Browse files Browse the repository at this point in the history
Rate responses
  • Loading branch information
AlexanderNeumann authored Oct 16, 2023
2 parents 2a61618 + 42c3fc4 commit c72aed6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class RESTfulChatResponse {
private InteractiveChatElementType type;
private JSONObject reqBody;
private boolean isFile;
private boolean rateable;


public RESTfulChatResponse(String text, HashMap<String, IncomingMessage> hashMap, String type) {
Expand All @@ -34,6 +35,9 @@ public RESTfulChatResponse(String text, HashMap<String, IncomingMessage> hashMap
if(value.expectsFile()){
isFile = true;
}
if(value.isRateable()){
rateable = true;
}
icel.add(ice);
}
}
Expand Down Expand Up @@ -92,4 +96,12 @@ public boolean isFile() {
public void setFile(boolean isFile) {
this.isFile = isFile;
}

public boolean isRateable() {
return rateable;
}

public void setRateable(boolean rateable) {
this.rateable = rateable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class IncomingMessage {
String type;
boolean openAIEnhance;
boolean freezeMessageSend;
boolean isRateable;

/**
* Conversation Id for the message
Expand Down Expand Up @@ -54,7 +55,7 @@ public static String replaceUmlaute(String orig) {


public IncomingMessage(String intent, String NluID, Boolean containsFile, ArrayList<String> responses,
String fileURL, String errorMessage, String type, String intentLabel, String followupType) {
String fileURL, String errorMessage, String type, String intentLabel, String followupType, Boolean isRateable) {
if (intent != "") {
this.intentKeyword = replaceUmlaute(intent);
} else
Expand All @@ -76,6 +77,7 @@ public IncomingMessage(String intent, String NluID, Boolean containsFile, ArrayL
this.type = type;
this.followupMessageType = followupType;
this.intentLabel = intentLabel;
this.isRateable = isRateable;
}

public UUID getConversationId() {
Expand Down Expand Up @@ -214,4 +216,13 @@ public void setFollowupMessageType(String followupMessageType) {
public void setFreezeMessageSend(boolean flag) {
this.freezeMessageSend = flag;
}

public boolean isRateable() {
return isRateable;
}


public void setRateable(boolean isRateable) {
this.isRateable = isRateable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ private Intent determineIntent(ChatMessage message, Bot bot) {
} else {
ArrayList<String> empty = new ArrayList<String>();
empty.add("");
incMsg = new IncomingMessage(intentKeyword, "", false, empty, null, "", null, "", "text");
incMsg = new IncomingMessage(intentKeyword, "", false, empty, null, "", null, "", "text", false);
if (splitMessage.length > 1) {
incMsg.setEntityKeyword(incMsg.getIntentKeyword());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ private IncomingMessage addIncomingMessage(String key, BotModelNode elem, BotCon
String type = null;
String intentLabel = null;
String followupMessageType = null;
Boolean isRateable = null;

// TODO: Reduce code duplication
try{
Expand Down Expand Up @@ -521,7 +522,9 @@ private IncomingMessage addIncomingMessage(String key, BotModelNode elem, BotCon
intentLabel = subVal.getValue();
} else if (name.contentEquals("Followup Message Type")) {
followupMessageType = subVal.getValue();
}
} else if (name.contentEquals("Rateable")){
isRateable = Boolean.valueOf(subVal.getValue());
}
}
} catch(Exception e){
System.out.println("Error: " + e.getMessage());
Expand Down Expand Up @@ -551,7 +554,7 @@ private IncomingMessage addIncomingMessage(String key, BotModelNode elem, BotCon
throw new ParseBotException("Response is missing Type");
}

return new IncomingMessage(intentKeyword, NluID, containsFile, messages, fileURL, errorMessage, type, intentLabel, followupMessageType);
return new IncomingMessage(intentKeyword, NluID, containsFile, messages, fileURL, errorMessage, type, intentLabel, followupMessageType, isRateable);
}

private IntentEntity addIntentEntity(String key, BotModelNode elem, BotConfiguration config)
Expand Down

0 comments on commit c72aed6

Please sign in to comment.