@@ -148,13 +148,13 @@ private static ImageParametersBuilder getImageParametersBuilder(VertexAiImagenIm
148
148
149
149
@ Override
150
150
public ImageResponse call (ImagePrompt imagePrompt ) {
151
- VertexAiImagenImageOptions finalOptions = mergedOptions (imagePrompt );
151
+ ImagePrompt finalPrompt = mergedPrompt (imagePrompt );
152
+ VertexAiImagenImageOptions finalOptions = (VertexAiImagenImageOptions ) finalPrompt .getOptions ();
152
153
153
154
var observationContext = ImageModelObservationContext .builder ()
154
- .imagePrompt (imagePrompt )
155
- .provider (AiProvider .VERTEX_AI .value ())
156
- .requestOptions (finalOptions )
157
- .build ();
155
+ .imagePrompt (finalPrompt )
156
+ .provider (AiProvider .VERTEX_AI .value ())
157
+ .build ();
158
158
159
159
return ImageModelObservationDocumentation .IMAGE_MODEL_OPERATION
160
160
.observation (this .observationConvention , DEFAULT_OBSERVATION_CONVENTION , () -> observationContext ,
@@ -164,7 +164,7 @@ public ImageResponse call(ImagePrompt imagePrompt) {
164
164
165
165
EndpointName endpointName = this .connectionDetails .getEndpointName (finalOptions .getModel ());
166
166
167
- PredictRequest .Builder predictRequestBuilder = getPredictRequestBuilder (imagePrompt , endpointName ,
167
+ PredictRequest .Builder predictRequestBuilder = getPredictRequestBuilder (finalPrompt , endpointName ,
168
168
finalOptions );
169
169
170
170
PredictResponse imageResponse = this .retryTemplate
@@ -175,7 +175,7 @@ public ImageResponse call(ImagePrompt imagePrompt) {
175
175
Value bytesBase64Encoded = prediction .getStructValue ().getFieldsOrThrow ("bytesBase64Encoded" );
176
176
Value mimeType = prediction .getStructValue ().getFieldsOrThrow ("mimeType" );
177
177
ImageGenerationMetadata metadata = new VertexAiImagenImageGenerationMetadata (
178
- imagePrompt .getInstructions ().get (0 ).getText (), finalOptions .getModel (),
178
+ finalPrompt .getInstructions ().get (0 ).getText (), finalOptions .getModel (),
179
179
mimeType .getStringValue ());
180
180
Image image = new Image (null , bytesBase64Encoded .getStringValue ());
181
181
imageGenerationList .add (new ImageGeneration (image , metadata ));
@@ -189,17 +189,16 @@ public ImageResponse call(ImagePrompt imagePrompt) {
189
189
});
190
190
}
191
191
192
- private VertexAiImagenImageOptions mergedOptions (ImagePrompt imagePrompt ) {
192
+ private ImagePrompt mergedPrompt (ImagePrompt originalPrompt ) {
193
+ VertexAiImagenImageOptions finalOptions = this .defaultOptions ;
193
194
194
- VertexAiImagenImageOptions mergedOptions = this .defaultOptions ;
195
-
196
- if (imagePrompt .getOptions () != null ) {
195
+ if (originalPrompt .getOptions () != null ) {
197
196
var defaultOptionsCopy = VertexAiImagenImageOptions .builder ().from (this .defaultOptions ).build ();
198
- mergedOptions = ModelOptionsUtils .merge (imagePrompt .getOptions (), defaultOptionsCopy ,
197
+ finalOptions = ModelOptionsUtils .merge (originalPrompt .getOptions (), defaultOptionsCopy ,
199
198
VertexAiImagenImageOptions .class );
200
199
}
201
200
202
- return mergedOptions ;
201
+ return new ImagePrompt ( originalPrompt . getInstructions (), finalOptions ) ;
203
202
}
204
203
205
204
protected PredictRequest .Builder getPredictRequestBuilder (ImagePrompt imagePrompt , EndpointName endpointName ,
0 commit comments