Skip to content

Commit a307a2b

Browse files
ThomasVitaletzolov
authored andcommitted
Deprecate redundant field in ModelObservationContext
Each ModelObservationContext takes both a request object (e.g. Prompt) and an options object (e.g. ChatOptions). However, the options are already included in the request object. This PR deprecates the additional field, which will be removed in a subsequent release. The reason why the extra field was there in the first place was due to the model implementations not handling request options correctly, requiring a dedicated setter. We started fixing the model implementations now, so we are deprecating te extra field, and we'll remove it in the next release, once we have completed the implementation of a fix for all model implementations. Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
1 parent 3393e98 commit a307a2b

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

spring-ai-core/src/main/java/org/springframework/ai/chat/observation/ChatModelObservationContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public static Builder builder() {
4545
return new Builder();
4646
}
4747

48+
/**
49+
* @deprecated Use {@link #getRequest().getOptions()} instead.
50+
*/
51+
@Deprecated(forRemoval = true)
4852
public ChatOptions getRequestOptions() {
4953
return this.requestOptions;
5054
}
@@ -70,6 +74,11 @@ public Builder provider(String provider) {
7074
return this;
7175
}
7276

77+
/**
78+
* @deprecated ChatOptions are passed in the Prompt object and should not be set
79+
* separately anymore.
80+
*/
81+
@Deprecated(forRemoval = true)
7382
public Builder requestOptions(ChatOptions requestOptions) {
7483
this.requestOptions = requestOptions;
7584
return this;

spring-ai-core/src/main/java/org/springframework/ai/embedding/observation/EmbeddingModelObservationContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public static Builder builder() {
4949
return new Builder();
5050
}
5151

52+
/**
53+
* @deprecated Use {@link #getRequest().getOptions()} instead.
54+
*/
55+
@Deprecated(forRemoval = true)
5256
public EmbeddingOptions getRequestOptions() {
5357
return this.requestOptions;
5458
}
@@ -74,6 +78,11 @@ public Builder provider(String provider) {
7478
return this;
7579
}
7680

81+
/**
82+
* @deprecated EmbeddingOptions are passed in the EmbeddingRequest object and
83+
* should not be set separately anymore.
84+
*/
85+
@Deprecated(forRemoval = true)
7786
public Builder requestOptions(EmbeddingOptions requestOptions) {
7887
this.requestOptions = requestOptions;
7988
return this;

spring-ai-core/src/main/java/org/springframework/ai/image/observation/ImageModelObservationContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public static Builder builder() {
4545
return new Builder();
4646
}
4747

48+
/**
49+
* @deprecated Use {@link #getRequest().getOptions()} instead.
50+
*/
51+
@Deprecated(forRemoval = true)
4852
public ImageOptions getRequestOptions() {
4953
return this.requestOptions;
5054
}
@@ -74,6 +78,11 @@ public Builder provider(String provider) {
7478
return this;
7579
}
7680

81+
/**
82+
* @deprecated ImageOptions are passed in the ImagePrompt object and should not be
83+
* set separately anymore.
84+
*/
85+
@Deprecated(forRemoval = true)
7786
public Builder requestOptions(ImageOptions requestOptions) {
7887
this.requestOptions = requestOptions;
7988
return this;

0 commit comments

Comments
 (0)