Skip to content

Commit

Permalink
Use own object mapper for deserialisation of LLM Qs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt47 committed Sep 10, 2024
1 parent 090489d commit 3631aea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ public MapperFacade getAutoMapper() {
* @return ObjectMapper that has been configured to handle the segue recursive object model.
*/
public ObjectMapper generateNewPreconfiguredContentMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

ContentBaseDeserializer contentDeserializer = new ContentBaseDeserializer();
contentDeserializer.registerTypeMap(jsonTypes);

Expand All @@ -368,9 +365,10 @@ public ObjectMapper generateNewPreconfiguredContentMapper() {
contentDeserializerModule.addDeserializer(Choice.class, choiceDeserializer);
contentDeserializerModule.addDeserializer(Item.class, itemDeserializer);
contentDeserializerModule.addDeserializer(QuestionValidationResponse.class, validationResponseDeserializer);
contentDeserializerModule.addDeserializer(
LLMMarkingExpression.class, new LLMMarkingExpressionDeserializer(objectMapper));
contentDeserializerModule.addDeserializer(LLMMarkingExpression.class, new LLMMarkingExpressionDeserializer());

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.registerModule(contentDeserializerModule);

return objectMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@
import java.io.IOException;

public class LLMMarkingExpressionDeserializer extends JsonDeserializer<LLMMarkingExpression> {
private final ObjectMapper objectMapper;

public LLMMarkingExpressionDeserializer(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

@Override
public LLMMarkingExpression deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext)
throws IOException {
ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec();
ObjectNode root = objectMapper.readTree(jsonParser);

if (null == root.get("type")) {
Expand Down

0 comments on commit 3631aea

Please sign in to comment.