File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/main/java/com/APIprotector/apiprotector/service Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .APIprotector .apiprotector .service ;
2
2
3
3
import org .springframework .beans .factory .annotation .Value ;
4
+ import org .springframework .http .HttpHeaders ;
4
5
import org .springframework .http .MediaType ;
5
6
import org .springframework .stereotype .Service ;
6
7
import org .springframework .web .reactive .function .BodyInserters ;
7
8
import org .springframework .web .reactive .function .client .WebClient ;
8
9
import reactor .core .publisher .Mono ;
10
+
11
+ import java .time .Duration ;
9
12
import java .util .Collections ;
10
13
import java .util .Map ;
11
14
@@ -31,7 +34,10 @@ public OverviewService(
31
34
throw new IllegalArgumentException ("Prompt is empty or not configured" );
32
35
}
33
36
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 ();
35
41
this .apiKey = apiKey ;
36
42
this .modelName = modelName ;
37
43
this .prompt = prompt ;
@@ -64,6 +70,7 @@ public Mono<String> sendPrompt(String prompt) {
64
70
.contentType (MediaType .APPLICATION_JSON )
65
71
.body (BodyInserters .fromValue (requestBody ))
66
72
.retrieve ()
67
- .bodyToMono (String .class );
73
+ .bodyToMono (String .class )
74
+ .timeout (Duration .ofMinutes (5 ));
68
75
}
69
76
}
You can’t perform that action at this time.
0 commit comments