Skip to content

Commit

Permalink
Merge pull request #785 from quarkiverse/ollama-pretty-print
Browse files Browse the repository at this point in the history
Pretty print Ollama responses
  • Loading branch information
geoand authored Jul 26, 2024
2 parents e8ae2d2 + b887b92 commit f2efe18
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.jboss.resteasy.reactive.client.api.ClientLogger;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.quarkiverse.langchain4j.QuarkusJsonCodecFactory;
Expand Down Expand Up @@ -210,7 +211,12 @@ private String bodyToString(Buffer body) {
if (body == null) {
return "";
}
return body.toString();
String rawBody = body.toString();
try {
return QuarkusJsonCodecFactory.SnakeCaseObjectMapperHolder.MAPPER.readTree(rawBody).toPrettyString();
} catch (JsonProcessingException ignored) {
return rawBody;
}
}

private String inOneLine(MultiMap headers) {
Expand Down

0 comments on commit f2efe18

Please sign in to comment.