mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 03:47:13 +02:00
Update OllamaAPI.java
This commit is contained in:
parent
ecb04d6d82
commit
5f19eb17ac
@ -164,6 +164,20 @@ public class OllamaAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> listDownloadableModels() throws OllamaBaseException, IOException, InterruptedException, URISyntaxException {
|
||||
String url = "https://ollama.com/library";
|
||||
HttpClient httpClient = HttpClient.newHttpClient();
|
||||
HttpRequest httpRequest = getRequestBuilderDefault(new URI(url)).header("Accept", "application/json").header("Content-type", "application/json").GET().build();
|
||||
HttpResponse<String> response = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
||||
int statusCode = response.statusCode();
|
||||
String responseString = response.body();
|
||||
if (statusCode == 200) {
|
||||
return null;
|
||||
} else {
|
||||
throw new OllamaBaseException(statusCode + " - " + responseString);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pull a model on the Ollama server from the list of <a
|
||||
* href="https://ollama.ai/library">available models</a>.
|
||||
|
Loading…
x
Reference in New Issue
Block a user