mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 11:57:12 +02:00
Updated askAsync
API to use OutputStream.write
instead of DataOutputStream.writeBytes
This commit is contained in:
parent
7c4b17454b
commit
df9b9af063
@ -17,7 +17,10 @@ import org.apache.hc.core5.http.io.entity.StringEntity;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -281,8 +284,8 @@ 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");
|
||||||
try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
|
try (OutputStream out = con.getOutputStream()) {
|
||||||
wr.writeBytes(ollamaRequestModel.toString());
|
out.write(ollamaRequestModel.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
OllamaAsyncResultCallback ollamaAsyncResultCallback = new OllamaAsyncResultCallback(con);
|
OllamaAsyncResultCallback ollamaAsyncResultCallback = new OllamaAsyncResultCallback(con);
|
||||||
ollamaAsyncResultCallback.start();
|
ollamaAsyncResultCallback.start();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user