davsclaus commented on code in PR #29034:
URL: https://github.com/apache/camel/pull/29034#discussion_r4451481178


##########
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:
   Checked against the jar in use (spring-ai-model 2.0.2): there is no public 
type or marker for the generic options. `ImageOptions` is implemented by both 
the generic and the provider options, and the class 
`ImageOptionsBuilder.build()` creates is the package-private 
`ImageOptionsBuilder.DefaultImageModelOptions`; `new ImagePrompt(text)` uses 
the same builder. So I kept taking the type from the builder (it follows a 
rename of that class) and added a comment on `GENERIC_OPTIONS_TYPE` explaining 
why and the version checked. New test 
`SpringAiImageProducerTest.genericOptionsTypeIsTheTypeOfTheBuilderAndOfAPromptWithoutOptions`
 asserts that the options of the builder (with values set) and of `new 
ImagePrompt(text)` are exactly that type and that provider options are not, so 
a change in Spring AI fails the build instead of silently changing the merge. 
Commit 4e11e291a21a.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_



##########
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:
   Done: the example comment now says the prompt options win per option, "the 
prompt width (1024) overrides the endpoint width (512), and the height the 
prompt leaves unset falls back to the endpoint height (512)". The catalog copy 
of the doc is updated. Commit 4e11e291a21a.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_



-- 
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