Skip to content

Commit

Permalink
Allow customization of invalid json reprompt
Browse files Browse the repository at this point in the history
  • Loading branch information
edeandrea committed Jan 8, 2025
1 parent 4afa2f2 commit b03f26d
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,19 @@ public OutputGuardrailResult validate(AiMessage responseFromLLM) {
}
}

return reprompt("Invalid JSON",
"Make sure you return a valid JSON object following "
+ "the specified format");
return invokeInvalidJson(responseFromLLM, json);
}

protected OutputGuardrailResult invokeInvalidJson(AiMessage aiMessage, String json) {
return reprompt(getInvalidJsonMessage(aiMessage, json), getInvalidJsonReprompt(aiMessage, json));
}

protected String getInvalidJsonMessage(AiMessage aiMessage, String json) {
return "Invalid JSON";
}

protected String getInvalidJsonReprompt(AiMessage aiMessage, String json) {
return "Make sure you return a valid JSON object following the specified format";
}

protected Object deserialize(String llmResponse) {
Expand Down

0 comments on commit b03f26d

Please sign in to comment.