Skip to content

Commit

Permalink
Merge pull request #1234 from MyRobotLab/sriax-update
Browse files Browse the repository at this point in the history
returns SRAIXFAILED (input) when wikipedia fails
  • Loading branch information
hairygael authored Jan 2, 2023
2 parents 26be2f2 + 635ed94 commit b936905
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/java/org/myrobotlab/programab/MrlSraixHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,23 @@ public String sraix(Chat chatSession, String input, String defaultResponse, Stri
try {
SearchPublisher search = (SearchPublisher) programab.getPeer("search");
if (search != null) {
SearchResults results = search.search(input);
return results.getTextAndImages();
SearchResults results = search.search(input);
String searchResponse = results.getTextAndImages();

if (searchResponse == null || searchResponse.length() == 0) {
Session session = programab.getSession();
// TODO - perhaps more rich codes for details of failure
// Response r = session.getResponse("SRAIXFAILED_WIKIPEDIA " + input);
Response r = session.getResponse("SRAIXFAILED " + input);
return r.msg;
}
return searchResponse;
} else {
return null;
// TODO - perhaps more rich codes for details of failure
// Response r = programab.getResponse("SRAIXFAILED_WIKIPEDIA_NOT_AVAILABLE");
Session session = programab.getSession();
Response r = session.getResponse("SRAIXFAILED " + input);
return r.msg;
}

} catch (Exception e) {
Expand Down

0 comments on commit b936905

Please sign in to comment.