|
60 | 60 | * @author Ricken Bazolo |
61 | 61 | * @author Christian Tzolov |
62 | 62 | * @author Thomas Vitale |
| 63 | + * @author jasonparallel |
63 | 64 | * @since 1.0.0 |
64 | 65 | */ |
65 | 66 | public class MistralAiApi { |
| 67 | + |
| 68 | + public static Builder builder() { |
| 69 | + return new Builder(); |
| 70 | + } |
66 | 71 |
|
67 | 72 | public static final String PROVIDER_NAME = AiProvider.MISTRAL_AI.value(); |
68 | 73 |
|
@@ -1074,4 +1079,42 @@ public record ChunkChoice( |
1074 | 1079 |
|
1075 | 1080 | } |
1076 | 1081 |
|
| 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 | + } |
1077 | 1120 | } |
0 commit comments