This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.14.x by this push:
new d43f9ec9456 CAMEL-22405: simplify working with non-text media for Ai
Agents
d43f9ec9456 is described below
commit d43f9ec94569d60f44aeb31d64a5264863fcb352
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Fri Sep 5 18:09:50 2025 +0200
CAMEL-22405: simplify working with non-text media for Ai Agents
---
.../langchain4j/agent/api/AiAgentBody.java | 68 +++++++++++++++++++---
1 file changed, 59 insertions(+), 9 deletions(-)
diff --git
a/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AiAgentBody.java
b/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AiAgentBody.java
index 06f74e42397..21a7030a1e8 100644
---
a/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AiAgentBody.java
+++
b/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AiAgentBody.java
@@ -21,12 +21,14 @@ package org.apache.camel.component.langchain4j.agent.api;
*
* <p>
* This class encapsulates all the information needed for a chat interaction
with an AI agent, including the user's
- * message, optional system instructions, and memory identification for
stateful conversations.
+ * message, optional system instructions, memory identification for stateful
conversations, and content for non-text
+ * media supported by LangChain4j.
* </p>
*
* <p>
* The class provides both constructor-based initialization and fluent
builder-style methods for convenient object
- * creation and configuration.
+ * creation and configuration. The generic type parameter {@code C} allows for
type-safe handling of various content
+ * types such as TextContent, ImageContent, AudioContent, VideoContent, or
PdfFileContent.
* </p>
*
* <p>
@@ -43,19 +45,22 @@ package org.apache.camel.component.langchain4j.agent.api;
* "You are a helpful weather assistant",
* "user123");
*
- * // Using fluent API
- * AiAgentBody body = new AiAgentBody()
- * .withUserMessage("Tell me a joke")
- * .withSystemMessage("You are a comedian")
- * .withMemoryId("session456");
+ * // Using fluent API with content
+ * AiAgentBody<ImageContent> body = new AiAgentBody<ImageContent>()
+ * .withUserMessage("What do you see in this image?")
+ * .withSystemMessage("You are an image analysis assistant")
+ * .withMemoryId("session456")
+ * .withContent(imageContent);
* }</pre>
*
- * @since 4.9.0
+ * @param <C> the type of content (e.g., TextContent, ImageContent,
AudioContent, VideoContent, PdfFileContent)
+ * @since 4.9.0
*/
-public class AiAgentBody {
+public class AiAgentBody<C> {
private String userMessage;
private String systemMessage;
private Object memoryId;
+ private C content;
/**
* Creates an empty AI agent body. Use the fluent setter methods to
configure the instance.
@@ -191,4 +196,49 @@ public class AiAgentBody {
public void setMemoryId(Object memoryId) {
this.memoryId = memoryId;
}
+
+ /**
+ * Gets the content.
+ *
+ * <p>
+ * The content can be any non-text media supported by LangChain4j, such as
TextContent, ImageContent, AudioContent,
+ * VideoContent, or PdfFileContent. This is not used by default by Camel,
instead, it can be used by custom agents.
+ * </p>
+ *
+ * @return the content object, or {@code null} if not set
+ */
+ public C getContent() {
+ return content;
+ }
+
+ /**
+ * Sets the content.
+ *
+ * <p>
+ * The content can be any non-text media supported by LangChain4j, such as
TextContent, ImageContent, AudioContent,
+ * VideoContent, or PdfFileContent. This is not used by default by Camel,
instead, it can be used by custom agents.
+ * </p>
+ *
+ * @param content the content object to set
+ */
+ public void setContent(C content) {
+ this.content = content;
+ }
+
+ /**
+ * Sets the content and returns this instance for method chaining.
+ *
+ * <p>
+ * The content can be any non-text media supported by LangChain4j, such as
TextContent, ImageContent, AudioContent,
+ * VideoContent, or PdfFileContent.This is not used by default by Camel,
instead, it can be used by custom agents.
+ * </p>
+ *
+ * @param content the content object to set
+ * @return this AiAgentBody instance for fluent method chaining
+ */
+ public AiAgentBody<C> withContent(C content) {
+ this.content = content;
+ return this;
+ }
+
}