gnodet-bot commented on code in PR #29034:
URL: https://github.com/apache/camel/pull/29034#discussion_r4449113678


##########
components/camel-spring-parent/camel-spring-ai/camel-spring-ai-image/src/main/java/org/apache/camel/component/springai/image/SpringAiImageProducer.java:
##########
@@ -31,6 +31,10 @@
 
 public class SpringAiImageProducer extends DefaultProducer {
 
+    // the type of the generic options of ImageOptionsBuilder and new 
ImagePrompt(text), as opposed to the
+    // options of a provider such as OpenAiImageOptions
+    private static final Class<?> GENERIC_OPTIONS_TYPE = 
ImageOptionsBuilder.builder().build().getClass();

Review Comment:
   💡 **Fragility concern:** `GENERIC_OPTIONS_TYPE` is detected via 
`ImageOptionsBuilder.builder().build().getClass()`, which captures a private 
inner class identity at class-load time. If Spring AI refactors 
`ImageOptionsBuilder` so that the no-arg builder produces a different concrete 
type (e.g. promotes the inner class or returns a different implementation), 
this guard will silently stop working — all `ImageOptions` instances will be 
treated as provider-specific and the merge will always apply.
   
   Consider using an explicit interface/marker check instead (e.g. checking 
`instanceof GenericImageOptions` or an equivalent public API), or at minimum 
adding a comment explaining the fragility and the Spring AI version this was 
validated against.



##########
components/camel-spring-parent/camel-spring-ai/camel-spring-ai-image/src/main/docs/spring-ai-image-component.adoc:
##########
@@ -109,6 +109,23 @@ Exchange exchange = template.request("direct:generate", e 
-> {
 });
 ----
 
+==== With an ImagePrompt body
+
+When the message body is an `org.springframework.ai.image.ImagePrompt`, the 
options it sets win, and the endpoint
+options and headers fill the options it leaves unset (`n`, `width`, `height`, 
`model`, `responseFormat` and `style`).
+This applies to the generic options of a prompt (`new ImagePrompt(text)` or 
options from `ImageOptionsBuilder`). The
+options of a provider, such as `OpenAiImageOptions`, are used as is, as a 
generic copy of them would lose the
+provider settings (for example the OpenAI `quality`).
+
+._Java-only: Java Spring AI SDK API_
+[source,java]
+----
+// width=1024 from the prompt, height=512 from the endpoint
+ImagePrompt prompt = new ImagePrompt("A red apple on a white table",
+    ImageOptionsBuilder.builder().width(1024).build());
+template.sendBody("spring-ai-image:gen?imageModel=#imageModel&width=512&height=512",
 prompt);

Review Comment:
   💡 **Doc clarity:** The comment says `width=1024 from the prompt, height=512 
from the endpoint`, but the endpoint URI has `width=512&height=512` — so the 
prompt silently overrides the endpoint's `width`. This is technically accurate 
but could confuse readers who see both values and wonder which wins.
   
   Consider adding a brief note that prompt options take priority over endpoint 
options when both specify the same field, e.g.:
   ```
   // Prompt width (1024) overrides endpoint width (512); height falls back to 
endpoint (512)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to