Class AbstractJsonExtractorOutputGuardrail
java.lang.Object
io.quarkiverse.langchain4j.guardrails.AbstractJsonExtractorOutputGuardrail
- All Implemented Interfaces:
Guardrail<OutputGuardrailParams,
,OutputGuardrailResult> OutputGuardrail
public abstract class AbstractJsonExtractorOutputGuardrail
extends Object
implements OutputGuardrail
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
deserialize
(String llmResponse) protected String
getInvalidJsonMessage
(dev.langchain4j.data.message.AiMessage aiMessage, String json) protected String
getInvalidJsonReprompt
(dev.langchain4j.data.message.AiMessage aiMessage, String json) protected Class
<?> protected com.fasterxml.jackson.core.type.TypeReference
<?> protected OutputGuardrailResult
invokeInvalidJson
(dev.langchain4j.data.message.AiMessage aiMessage, String json) validate
(dev.langchain4j.data.message.AiMessage responseFromLLM) Validates the response from the LLM.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.quarkiverse.langchain4j.guardrails.OutputGuardrail
failure, failure, fatal, fatal, reprompt, reprompt, retry, retry, success, successWith, successWith, validate
-
Constructor Details
-
AbstractJsonExtractorOutputGuardrail
protected AbstractJsonExtractorOutputGuardrail()
-
-
Method Details
-
validate
Description copied from interface:OutputGuardrail
Validates the response from the LLM.- Specified by:
validate
in interfaceOutputGuardrail
- Parameters:
responseFromLLM
- the response from the LLM
-
invokeInvalidJson
protected OutputGuardrailResult invokeInvalidJson(dev.langchain4j.data.message.AiMessage aiMessage, String json) -
getInvalidJsonMessage
-
getInvalidJsonReprompt
-
deserialize
-
getOutputClass
-
getOutputType
protected com.fasterxml.jackson.core.type.TypeReference<?> getOutputType()
-