File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
orchestration/src/main/java/com/sap/ai/sdk/orchestration Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -122,11 +122,23 @@ public LLMChoice getChoice() {
122122 */
123123 @ Nonnull
124124 public <T > T entity (@ Nonnull final Class <T > type ) {
125+ String refusal =
126+ ((LLMModuleResultSynchronous ) getOriginalResponse ().getOrchestrationResult ())
127+ .getChoices ()
128+ .get (0 )
129+ .getMessage ()
130+ .getRefusal ();
131+ if (refusal != null ) {
132+ throw new OrchestrationClientException (
133+ "The model refused to answer the question: " + refusal );
134+ }
125135 try {
126136 return new ObjectMapper ().readValue (getContent (), type );
127137 } catch (JsonProcessingException e ) {
128138 throw new OrchestrationClientException (
129- "Failed to deserialize the JSON content: " + e .getMessage (), e );
139+ "Failed to deserialize the JSON content, please configure an OrchestrationTemplate with format set to JSON schema into your OrchestrationModuleConfig"
140+ + e .getMessage (),
141+ e );
130142 }
131143 }
132144}
You can’t perform that action at this time.
0 commit comments