From 9d4a8ad0283de72fcb81adca7f1adbfc50f97c53 Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Wed, 6 Nov 2024 21:19:22 +0100 Subject: [PATCH] #5149 - Page hangs when listing LLM models is not possible - Set a 10 second timeout for model listing calls --- .../recommendation/imls/chatgpt/client/ChatGptClientImpl.java | 2 ++ .../recommendation/imls/hf/client/HfHubClientImpl.java | 2 ++ .../recommendation/imls/ollama/client/OllamaClientImpl.java | 2 ++ 3 files changed, 6 insertions(+) diff --git a/inception/inception-imls-chatgpt/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/chatgpt/client/ChatGptClientImpl.java b/inception/inception-imls-chatgpt/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/chatgpt/client/ChatGptClientImpl.java index b4c47743dd6..c5bba54eefc 100644 --- a/inception/inception-imls-chatgpt/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/chatgpt/client/ChatGptClientImpl.java +++ b/inception/inception-imls-chatgpt/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/chatgpt/client/ChatGptClientImpl.java @@ -29,6 +29,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; +import java.time.Duration; import java.util.Comparator; import java.util.List; import java.util.Map; @@ -141,6 +142,7 @@ public List listModels(String aUrl, ListModelsRequest aRequest) th .uri(URI.create(appendIfMissing(aUrl, "/") + "models")) // .header(HttpHeaders.CONTENT_TYPE, "application/json").GET() // .header("Authorization", "Bearer " + aRequest.getApiKey()) // + .timeout(Duration.ofSeconds(10)) // .build(); var response = sendRequest(request); diff --git a/inception/inception-imls-hf/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/hf/client/HfHubClientImpl.java b/inception/inception-imls-hf/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/hf/client/HfHubClientImpl.java index 408a530f62e..bf9813ce215 100644 --- a/inception/inception-imls-hf/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/hf/client/HfHubClientImpl.java +++ b/inception/inception-imls-hf/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/hf/client/HfHubClientImpl.java @@ -24,6 +24,7 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.time.Duration; import java.util.LinkedHashMap; import java.util.Map; @@ -82,6 +83,7 @@ public HfModelCard[] queryCatalog(Map aQueryParameters) throws I HttpRequest request = HttpRequest.newBuilder() // .uri(URI.create(uriBuilder.toString())) // + .timeout(Duration.ofSeconds(10)) // .build(); HttpResponse response = sendRequest(request); diff --git a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/client/OllamaClientImpl.java b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/client/OllamaClientImpl.java index e229c667681..2cb4b27ef16 100644 --- a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/client/OllamaClientImpl.java +++ b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/client/OllamaClientImpl.java @@ -30,6 +30,7 @@ import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; +import java.time.Duration; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -142,6 +143,7 @@ public List listModels(String aUrl) throws IOException var request = HttpRequest.newBuilder() // .uri(URI.create(appendIfMissing(aUrl, "/") + "api/tags")) // .header(HttpHeaders.CONTENT_TYPE, "application/json").GET() // + .timeout(Duration.ofSeconds(10)) // .build(); var response = sendRequest(request);