Adjust the retry properties names and documentation
This commit is contained in:
@@ -41,7 +41,9 @@ TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Man
|
||||
|
||||
=== Image Generation Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the OpenAI Chat client.
|
||||
==== Retry Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the OpenAI Image client.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|====
|
||||
@@ -51,10 +53,11 @@ The prefix `spring.ai.retry` is used as the property prefix that lets you config
|
||||
| spring.ai.retry.backoff.initial-interval | Initial sleep duration for the exponential backoff policy. | 2 sec.
|
||||
| spring.ai.retry.backoff.multiplier | Backoff interval multiplier. | 5
|
||||
| spring.ai.retry.backoff.max-interval | Maximum backoff duration. | 3 min.
|
||||
| spring.ai.retry.on-client-errors | If true, do not throw a NonTransientAiException, and do not attempt retry for 4xx client error codes | false
|
||||
| spring.ai.retry.on-http-codes | List of HTTP Error Code to include for retry | empty
|
||||
| spring.ai.retry.on-client-errors | If false, throw a NonTransientAiException, and do not attempt retry for `4xx` client error codes | false
|
||||
| spring.ai.retry.exclude-on-http-codes | List of HTTP status codes that should not trigger a retry (e.g. to throw NonTransientAiException). | empty
|
||||
|====
|
||||
|
||||
==== Connection Properties
|
||||
|
||||
The prefix `spring.ai.openai` is used as the property prefix that lets you connect to OpenAI.
|
||||
|
||||
@@ -65,6 +68,8 @@ The prefix `spring.ai.openai` is used as the property prefix that lets you conne
|
||||
| spring.ai.openai.api-key | The API Key | -
|
||||
|====
|
||||
|
||||
==== Configuration Properties
|
||||
|
||||
The prefix `spring.ai.openai.image` is the property prefix that lets you configure the `ImageClient` implementation for OpenAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|
||||
@@ -49,7 +49,9 @@ TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Man
|
||||
|
||||
=== Chat Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the OpenAI Chat client.
|
||||
==== Retry Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the Mistral AI Chat client.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|====
|
||||
@@ -59,10 +61,12 @@ The prefix `spring.ai.retry` is used as the property prefix that lets you config
|
||||
| spring.ai.retry.backoff.initial-interval | Initial sleep duration for the exponential backoff policy. | 2 sec.
|
||||
| spring.ai.retry.backoff.multiplier | Backoff interval multiplier. | 5
|
||||
| spring.ai.retry.backoff.max-interval | Maximum backoff duration. | 3 min.
|
||||
| spring.ai.retry.on-client-errors | If true, do not throw a NonTransientAiException, and do not attempt retry for 4xx client error codes | false
|
||||
| spring.ai.retry.on-http-codes | List of HTTP Error Code to include for retry | empty
|
||||
| spring.ai.retry.on-client-errors | If false, throw a NonTransientAiException, and do not attempt retry for `4xx` client error codes | false
|
||||
| spring.ai.retry.exclude-on-http-codes | List of HTTP status codes that should not trigger a retry (e.g. to throw NonTransientAiException). | empty
|
||||
|====
|
||||
|
||||
==== Connection Properties
|
||||
|
||||
The prefix `spring.ai.mistralai` is used as the property prefix that lets you connect to OpenAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
@@ -73,6 +77,8 @@ The prefix `spring.ai.mistralai` is used as the property prefix that lets you co
|
||||
| spring.ai.mistralai.api-key | The API Key | -
|
||||
|====
|
||||
|
||||
==== Configuration Properties
|
||||
|
||||
The prefix `spring.ai.mistralai.chat` is the property prefix that lets you configure the chat client implementation for MistralAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|
||||
@@ -49,6 +49,8 @@ TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Man
|
||||
|
||||
=== Chat Properties
|
||||
|
||||
==== Retry Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the OpenAI Chat client.
|
||||
|
||||
[cols="3,5,1"]
|
||||
@@ -59,10 +61,12 @@ The prefix `spring.ai.retry` is used as the property prefix that lets you config
|
||||
| spring.ai.retry.backoff.initial-interval | Initial sleep duration for the exponential backoff policy. | 2 sec.
|
||||
| spring.ai.retry.backoff.multiplier | Backoff interval multiplier. | 5
|
||||
| spring.ai.retry.backoff.max-interval | Maximum backoff duration. | 3 min.
|
||||
| spring.ai.retry.on-client-errors | If true, do not throw a NonTransientAiException, and do not attempt retry for 4xx client error codes | false
|
||||
| spring.ai.retry.on-http-codes | List of HTTP Error Code to include for retry | empty
|
||||
| spring.ai.retry.on-client-errors | If false, throw a NonTransientAiException, and do not attempt retry for `4xx` client error codes | false
|
||||
| spring.ai.retry.exclude-on-http-codes | List of HTTP status codes that should not trigger a retry (e.g. to throw NonTransientAiException). | empty
|
||||
|====
|
||||
|
||||
==== Connection Properties
|
||||
|
||||
The prefix `spring.ai.openai` is used as the property prefix that lets you connect to OpenAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
@@ -73,6 +77,9 @@ The prefix `spring.ai.openai` is used as the property prefix that lets you conne
|
||||
| spring.ai.openai.api-key | The API Key | -
|
||||
|====
|
||||
|
||||
|
||||
==== Configuration Properties
|
||||
|
||||
The prefix `spring.ai.openai.chat` is the property prefix that lets you configure the chat client implementation for OpenAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|
||||
@@ -49,6 +49,24 @@ TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Man
|
||||
|
||||
=== Embedding Properties
|
||||
|
||||
==== Retry Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the Mistral AI Embedding client.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|====
|
||||
| Property | Description | Default
|
||||
|
||||
| spring.ai.retry.max-attempts | Maximum number of retry attempts. | 10
|
||||
| spring.ai.retry.backoff.initial-interval | Initial sleep duration for the exponential backoff policy. | 2 sec.
|
||||
| spring.ai.retry.backoff.multiplier | Backoff interval multiplier. | 5
|
||||
| spring.ai.retry.backoff.max-interval | Maximum backoff duration. | 3 min.
|
||||
| spring.ai.retry.on-client-errors | If false, throw a NonTransientAiException, and do not attempt retry for `4xx` client error codes | false
|
||||
| spring.ai.retry.exclude-on-http-codes | List of HTTP status codes that should not trigger a retry (e.g. to throw NonTransientAiException). | empty
|
||||
|====
|
||||
|
||||
==== Connection Properties
|
||||
|
||||
The prefix `spring.ai.mistralai` is used as the property prefix that lets you connect to MistralAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
@@ -59,6 +77,8 @@ The prefix `spring.ai.mistralai` is used as the property prefix that lets you co
|
||||
| spring.ai.mistralai.api-key | The API Key | -
|
||||
|====
|
||||
|
||||
==== Configuration Properties
|
||||
|
||||
The prefix `spring.ai.mistralai.embedding` is property prefix that configures the `EmbeddingClient` implementation for MistralAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|
||||
@@ -50,7 +50,9 @@ TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Man
|
||||
|
||||
=== Embedding Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the OpenAI Chat client.
|
||||
==== Retry Properties
|
||||
|
||||
The prefix `spring.ai.retry` is used as the property prefix that lets you configure the retry mechanism for the OpenAI Embedding client.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|====
|
||||
@@ -60,8 +62,12 @@ The prefix `spring.ai.retry` is used as the property prefix that lets you config
|
||||
| spring.ai.retry.backoff.initial-interval | Initial sleep duration for the exponential backoff policy. | 2 sec.
|
||||
| spring.ai.retry.backoff.multiplier | Backoff interval multiplier. | 5
|
||||
| spring.ai.retry.backoff.max-interval | Maximum backoff duration. | 3 min.
|
||||
| spring.ai.retry.on-client-errors | If false, throw a NonTransientAiException, and do not attempt retry for `4xx` client error codes | false
|
||||
| spring.ai.retry.exclude-on-http-codes | List of HTTP status codes that should not trigger a retry (e.g. to throw NonTransientAiException). | empty
|
||||
|====
|
||||
|
||||
==== Connection Properties
|
||||
|
||||
The prefix `spring.ai.openai` is used as the property prefix that lets you connect to OpenAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
@@ -72,6 +78,8 @@ The prefix `spring.ai.openai` is used as the property prefix that lets you conne
|
||||
| spring.ai.openai.api-key | The API Key | -
|
||||
|====
|
||||
|
||||
==== Configuration Properties
|
||||
|
||||
The prefix `spring.ai.openai.embedding` is property prefix that configures the `EmbeddingClient` implementation for OpenAI.
|
||||
|
||||
[cols="3,5,1"]
|
||||
|
||||
@@ -95,8 +95,8 @@ public class SpringAiRetryAutoConfiguration {
|
||||
throw new NonTransientAiException(message);
|
||||
}
|
||||
// Explicitly configured non-transient codes
|
||||
if (!CollectionUtils.isEmpty(properties.getOnHttpCodes())
|
||||
&& properties.getOnHttpCodes().contains(response.getStatusCode().value())) {
|
||||
if (!CollectionUtils.isEmpty(properties.getExcludeOnHttpCodes())
|
||||
&& properties.getExcludeOnHttpCodes().contains(response.getStatusCode().value())) {
|
||||
throw new NonTransientAiException(message);
|
||||
}
|
||||
throw new TransientAiException(message);
|
||||
|
||||
@@ -42,13 +42,17 @@ public class SpringAiRetryProperties {
|
||||
private Backoff backoff = new Backoff();
|
||||
|
||||
/**
|
||||
* If true, do not throw a NonTransientAiException, and do not attempt retry for 4xx
|
||||
* client error codes false by default.
|
||||
*
|
||||
* If false, throw a NonTransientAiException, and do not attempt retry for 4xx client
|
||||
* error codes. False by default. If true, throw a TransientAiException, and attempt
|
||||
* retry for 4xx client.
|
||||
*/
|
||||
private boolean onClientErrors = false;
|
||||
|
||||
private List<Integer> onHttpCodes = new ArrayList<>();
|
||||
/**
|
||||
* List of HTTP status codes that should not trigger a retry (e.g. throw
|
||||
* NonTransientAiException).
|
||||
*/
|
||||
private List<Integer> excludeOnHttpCodes = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Exponential Backoff properties.
|
||||
@@ -108,12 +112,12 @@ public class SpringAiRetryProperties {
|
||||
return this.backoff;
|
||||
}
|
||||
|
||||
public List<Integer> getOnHttpCodes() {
|
||||
return this.onHttpCodes;
|
||||
public List<Integer> getExcludeOnHttpCodes() {
|
||||
return this.excludeOnHttpCodes;
|
||||
}
|
||||
|
||||
public void setOnHttpCodes(List<Integer> onHttpCodes) {
|
||||
this.onHttpCodes = onHttpCodes;
|
||||
public void setExcludeOnHttpCodes(List<Integer> onHttpCodes) {
|
||||
this.excludeOnHttpCodes = onHttpCodes;
|
||||
}
|
||||
|
||||
public boolean isOnClientErrors() {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SpringAiRetryPropertiesTests {
|
||||
assertThat(retryProperties.isOnClientErrors()).isFalse(); // do not retry
|
||||
// on 4xx
|
||||
// errors
|
||||
assertThat(retryProperties.getOnHttpCodes()).isEmpty();
|
||||
assertThat(retryProperties.getExcludeOnHttpCodes()).isEmpty();
|
||||
assertThat(retryProperties.getBackoff().getInitialInterval().toMillis()).isEqualTo(2000);
|
||||
assertThat(retryProperties.getBackoff().getMultiplier()).isEqualTo(5);
|
||||
assertThat(retryProperties.getBackoff().getMaxInterval().toMillis()).isEqualTo(3 * 60000);
|
||||
@@ -54,7 +54,7 @@ public class SpringAiRetryPropertiesTests {
|
||||
// @formatter:off
|
||||
"spring.ai.retry.max-attempts=100",
|
||||
"spring.ai.retry.on-client-errors=false",
|
||||
"spring.ai.retry.on-http-codes=404,500",
|
||||
"spring.ai.retry.exclude-on-http-codes=404,500",
|
||||
"spring.ai.retry.backoff.initial-interval=1000",
|
||||
"spring.ai.retry.backoff.multiplier=2",
|
||||
"spring.ai.retry.backoff.max-interval=60000" )
|
||||
@@ -65,7 +65,7 @@ public class SpringAiRetryPropertiesTests {
|
||||
|
||||
assertThat(retryProperties.getMaxAttempts()).isEqualTo(100);
|
||||
assertThat(retryProperties.isOnClientErrors()).isFalse();
|
||||
assertThat(retryProperties.getOnHttpCodes()).containsExactly(404, 500);
|
||||
assertThat(retryProperties.getExcludeOnHttpCodes()).containsExactly(404, 500);
|
||||
assertThat(retryProperties.getBackoff().getInitialInterval().toMillis()).isEqualTo(1000);
|
||||
assertThat(retryProperties.getBackoff().getMultiplier()).isEqualTo(2);
|
||||
assertThat(retryProperties.getBackoff().getMaxInterval().toMillis()).isEqualTo(60000);
|
||||
|
||||
Reference in New Issue
Block a user