mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 11:57:12 +02:00
Handled ignorable JSON fields of Ollama response
This commit is contained in:
parent
3a45746a63
commit
7c4b17454b
@ -1,5 +1,6 @@
|
|||||||
package io.github.amithkoujalgi.ollama4j.core;
|
package io.github.amithkoujalgi.ollama4j.core;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.github.amithkoujalgi.ollama4j.core.exceptions.OllamaBaseException;
|
import io.github.amithkoujalgi.ollama4j.core.exceptions.OllamaBaseException;
|
||||||
import io.github.amithkoujalgi.ollama4j.core.models.*;
|
import io.github.amithkoujalgi.ollama4j.core.models.*;
|
||||||
@ -33,7 +34,8 @@ public class OllamaAPI {
|
|||||||
private final String host;
|
private final String host;
|
||||||
private boolean verbose = false;
|
private boolean verbose = false;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper()
|
||||||
|
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates the Ollama API.
|
* Instantiates the Ollama API.
|
||||||
@ -240,6 +242,7 @@ public class OllamaAPI {
|
|||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.setRequestProperty("Content-Type", "application/json");
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
System.out.println(ollamaRequestModel.toString());
|
||||||
try (OutputStream out = con.getOutputStream()) {
|
try (OutputStream out = con.getOutputStream()) {
|
||||||
out.write(ollamaRequestModel.toString().getBytes(StandardCharsets.UTF_8));
|
out.write(ollamaRequestModel.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user