Skip to content

Commit

Permalink
Pretty print Ollama responses
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jul 26, 2024
1 parent e8ae2d2 commit b887b92
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 b887b92

Please sign in to comment.