Skip to content

Commit 3ad2acc

Browse files
Handle JsonProcessingException fallback
Signed-off-by: cho-thinkfree-com <[email protected]>
1 parent 46b9170 commit 3ad2acc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModel.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.fasterxml.jackson.annotation.JsonInclude;
2525
import com.fasterxml.jackson.annotation.JsonInclude.Include;
26+
import com.fasterxml.jackson.core.JsonProcessingException;
2627
import com.fasterxml.jackson.databind.JsonNode;
2728
import com.google.cloud.vertexai.VertexAI;
2829
import com.google.cloud.vertexai.api.Candidate;
@@ -371,8 +372,11 @@ else if (rootNode.isArray()) {
371372

372373
return structBuilder.build();
373374
}
374-
catch (Exception e) {
375-
throw new RuntimeException(e);
375+
catch (JsonProcessingException ex) {
376+
return Struct.newBuilder().putFields("result", Value.newBuilder().setStringValue(json).build()).build();
377+
}
378+
catch (Exception ex) {
379+
throw new RuntimeException(ex);
376380
}
377381
}
378382

0 commit comments

Comments
 (0)