Skip to content

Commit

Permalink
#5149 - Page hangs when listing LLM models is not possible
Browse files Browse the repository at this point in the history
- Set a 10 second timeout for model listing calls
  • Loading branch information
reckart committed Nov 6, 2024
1 parent f45d19f commit 9d4a8ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -141,6 +142,7 @@ public List<ChatGptModel> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -82,6 +83,7 @@ public HfModelCard[] queryCatalog(Map<String, String> aQueryParameters) throws I

HttpRequest request = HttpRequest.newBuilder() //
.uri(URI.create(uriBuilder.toString())) //
.timeout(Duration.ofSeconds(10)) //
.build();

HttpResponse<String> response = sendRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -142,6 +143,7 @@ public List<OllamaModel> 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);
Expand Down

0 comments on commit 9d4a8ad

Please sign in to comment.