Skip to content

Commit 1e84881

Browse files
committed
Add missing builder to follow project patterns
Signed-off-by: Jason Smith <[email protected]>
1 parent 925def2 commit 1e84881

File tree

1 file changed

+43
-0
lines changed
  • models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/api

1 file changed

+43
-0
lines changed

models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/api/MistralAiApi.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@
6060
* @author Ricken Bazolo
6161
* @author Christian Tzolov
6262
* @author Thomas Vitale
63+
* @author jasonparallel
6364
* @since 1.0.0
6465
*/
6566
public class MistralAiApi {
67+
68+
public static Builder builder() {
69+
return new Builder();
70+
}
6671

6772
public static final String PROVIDER_NAME = AiProvider.MISTRAL_AI.value();
6873

@@ -1074,4 +1079,42 @@ public record ChunkChoice(
10741079

10751080
}
10761081

1082+
public static class Builder {
1083+
1084+
private String baseUrl = DEFAULT_BASE_URL;
1085+
1086+
private RestClient.Builder restClientBuilder = RestClient.builder();
1087+
1088+
private WebClient.Builder webClientBuilder = WebClient.builder();
1089+
1090+
private ResponseErrorHandler responseErrorHandler = RetryUtils.DEFAULT_RESPONSE_ERROR_HANDLER;
1091+
1092+
public Builder baseUrl(String baseUrl) {
1093+
Assert.hasText(baseUrl, "baseUrl cannot be null or empty");
1094+
this.baseUrl = baseUrl;
1095+
return this;
1096+
}
1097+
1098+
public Builder restClientBuilder(RestClient.Builder restClientBuilder) {
1099+
Assert.notNull(restClientBuilder, "restClientBuilder cannot be null");
1100+
this.restClientBuilder = restClientBuilder;
1101+
return this;
1102+
}
1103+
1104+
public Builder webClientBuilder(WebClient.Builder webClientBuilder) {
1105+
Assert.notNull(webClientBuilder, "webClientBuilder cannot be null");
1106+
this.webClientBuilder = webClientBuilder;
1107+
return this;
1108+
}
1109+
1110+
public Builder responseErrorHandler(ResponseErrorHandler responseErrorHandler) {
1111+
Assert.notNull(responseErrorHandler, "responseErrorHandler cannot be null");
1112+
this.responseErrorHandler = responseErrorHandler;
1113+
return this;
1114+
}
1115+
1116+
public MistralAiApi build() {
1117+
return new MistralAiApi(this.baseUrl, this.baseUrl, this.restClientBuilder, this.webClientBuilder, this.responseErrorHandler);
1118+
}
1119+
}
10771120
}

0 commit comments

Comments
 (0)