Skip to content

Commit b4af2ba

Browse files
Increased timeouts to 5 minutes
1 parent efe0e2f commit b4af2ba

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/com/APIprotector/apiprotector/service/OverviewService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.APIprotector.apiprotector.service;
22

33
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.http.HttpHeaders;
45
import org.springframework.http.MediaType;
56
import org.springframework.stereotype.Service;
67
import org.springframework.web.reactive.function.BodyInserters;
78
import org.springframework.web.reactive.function.client.WebClient;
89
import reactor.core.publisher.Mono;
10+
11+
import java.time.Duration;
912
import java.util.Collections;
1013
import java.util.Map;
1114

@@ -31,7 +34,10 @@ public OverviewService(
3134
throw new IllegalArgumentException("Prompt is empty or not configured");
3235
}
3336

34-
this.webClient = webClientBuilder.baseUrl(baseUrl).build();
37+
this.webClient = webClientBuilder
38+
.baseUrl(baseUrl)
39+
.defaultHeaders(headers -> headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
40+
.build();
3541
this.apiKey = apiKey;
3642
this.modelName = modelName;
3743
this.prompt = prompt;
@@ -64,6 +70,7 @@ public Mono<String> sendPrompt(String prompt) {
6470
.contentType(MediaType.APPLICATION_JSON)
6571
.body(BodyInserters.fromValue(requestBody))
6672
.retrieve()
67-
.bodyToMono(String.class);
73+
.bodyToMono(String.class)
74+
.timeout(Duration.ofMinutes(5));
6875
}
6976
}

0 commit comments

Comments
 (0)