The nativeUsage
object within DefaultUsage
may not be JSON serialisable and hence causes a crash when using SimpleLoggingAdvisor
.
I've hit this when using VertexAI, where the nativeUsage
instance, which is cast as an Object
, is a protobuf of type GenerateContentRepsonse$UsageMetadata
.
This can't be serialised for pretty printing within the SimpleLoggerAdvisor repsonse code, which calls ModelOptionsUtils#toJsonStringPrettyPrinter
and thus throws an Exception.
public static String toJsonStringPrettyPrinter(Object object) {
try {
return OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(object);
}
catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
I think simplest solution would be to add a @JsonIgnore
to DefaultUsage#getNativeUsage
as it's not always obvious if it can be logged.