This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit b9d809806811d2771663de80c99810fa3a4fe1b4 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Fri Sep 12 16:25:59 2025 +0200 CAMEL-22405: simplify working with non-text media for Ai Agents --- .../apache/camel/component/langchain4j/agent/api/AiAgentBody.java | 6 +++--- .../langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java | 6 +++--- .../langchain4j/agent/integration/LangChain4jAgentServiceIT.java | 2 +- .../agent/integration/LangChain4jAgentWithMemoryServiceIT.java | 8 ++++---- .../agent/integration/LangChain4jAgentWithToolsIT.java | 2 +- .../langchain4j/agent/integration/LangChain4jSimpleAgentIT.java | 2 +- 6 files changed, 13 insertions(+), 13 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 21a7030a1e8..f07eb022f8a 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 @@ -96,7 +96,7 @@ public class AiAgentBody<C> { * @param userMessage the message from the user to send to the AI agent * @return this AiAgentBody instance for fluent method chaining */ - public AiAgentBody withUserMessage(String userMessage) { + public AiAgentBody<C> withUserMessage(String userMessage) { this.userMessage = userMessage; return this; } @@ -112,7 +112,7 @@ public class AiAgentBody<C> { * @param systemMessage the system instructions for the AI agent behavior * @return this AiAgentBody instance for fluent method chaining */ - public AiAgentBody withSystemMessage(String systemMessage) { + public AiAgentBody<C> withSystemMessage(String systemMessage) { this.systemMessage = systemMessage; return this; } @@ -129,7 +129,7 @@ public class AiAgentBody<C> { * @param memoryId the identifier for conversation memory (typically a string or number) * @return this AiAgentBody instance for fluent method chaining */ - public AiAgentBody withMemoryId(Object memoryId) { + public AiAgentBody<C> withMemoryId(Object memoryId) { this.memoryId = memoryId; return this; } diff --git a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java index a4f08350834..7d4bb46bcec 100644 --- a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java +++ b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java @@ -76,7 +76,7 @@ public class LangChain4jAgentWithMemoryServiceTest extends BaseLangChain4jAgent MockEndpoint mockEndpoint = this.context.getEndpoint("mock:agent-response", MockEndpoint.class); mockEndpoint.expectedMessageCount(3); - AiAgentBody firstRequest = new AiAgentBody( + AiAgentBody<?> firstRequest = new AiAgentBody<>( "Hi! Can you look up user 123 and tell me about our rental policies?", null, MEMORY_ID_SESSION); @@ -93,7 +93,7 @@ public class LangChain4jAgentWithMemoryServiceTest extends BaseLangChain4jAgent .withFailMessage("Response should contain rental policy information from RAG"); // Second interaction: Follow-up question - AiAgentBody secondRequest = new AiAgentBody( + AiAgentBody<?> secondRequest = new AiAgentBody<>( "What's his preferred vehicle type?", null, MEMORY_ID_SESSION); @@ -107,7 +107,7 @@ public class LangChain4jAgentWithMemoryServiceTest extends BaseLangChain4jAgent Assertions.assertThat(secondResponse).isEqualTo("SUV"); // Third interaction: Follow-up weather question - AiAgentBody thirdRequest = new AiAgentBody( + AiAgentBody<?> thirdRequest = new AiAgentBody<>( "What's the weather in London?", null, MEMORY_ID_SESSION); diff --git a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentServiceIT.java b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentServiceIT.java index c767ff78589..cd16ab27eb9 100644 --- a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentServiceIT.java +++ b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentServiceIT.java @@ -52,7 +52,7 @@ public class LangChain4jAgentServiceIT extends AbstractRAGIT { MockEndpoint mockEndpoint = this.context.getEndpoint("mock:agent-response", MockEndpoint.class); mockEndpoint.expectedMessageCount(1); - AiAgentBody request = new AiAgentBody( + AiAgentBody<?> request = new AiAgentBody<>( """ Can you look up user 123 and tell me about our rental policies? Please provide the response in this JSON format: diff --git a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithMemoryServiceIT.java b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithMemoryServiceIT.java index eb636bbc18a..4d3fb33d5c4 100644 --- a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithMemoryServiceIT.java +++ b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithMemoryServiceIT.java @@ -86,7 +86,7 @@ public class LangChain4jAgentWithMemoryServiceIT extends AbstractRAGIT { MockEndpoint mockEndpoint = this.context.getEndpoint("mock:agent-response", MockEndpoint.class); mockEndpoint.expectedMessageCount(2); - AiAgentBody firstRequest = new AiAgentBody( + AiAgentBody<?> firstRequest = new AiAgentBody<>( "Hi! Can you look up user 123 and tell me about our rental policies?", null, MEMORY_ID_SESSION); @@ -103,7 +103,7 @@ public class LangChain4jAgentWithMemoryServiceIT extends AbstractRAGIT { "Response should contain rental policy information from RAG"); // Second interaction: Follow-up question - AiAgentBody secondRequest = new AiAgentBody( + AiAgentBody<?> secondRequest = new AiAgentBody<>( "What's his preferred vehicle type?", null, MEMORY_ID_SESSION); @@ -133,7 +133,7 @@ public class LangChain4jAgentWithMemoryServiceIT extends AbstractRAGIT { MockEndpoint mockEndpoint = this.context.getEndpoint("mock:agent-response", MockEndpoint.class); mockEndpoint.expectedMessageCount(1); - AiAgentBody request = new AiAgentBody( + AiAgentBody<?> request = new AiAgentBody<>( """ Please provide user 123's information in this exact JSON format: { @@ -169,7 +169,7 @@ public class LangChain4jAgentWithMemoryServiceIT extends AbstractRAGIT { MockEndpoint mockEndpoint = this.context.getEndpoint("mock:agent-response", MockEndpoint.class); mockEndpoint.expectedMessageCount(1); - AiAgentBody request = new AiAgentBody( + AiAgentBody<?> request = new AiAgentBody<>( "What are your business hours on weekends?", null, MEMORY_ID_SESSION); diff --git a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithToolsIT.java b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithToolsIT.java index 00ec97bc7ef..eba6c2b2f6d 100644 --- a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithToolsIT.java +++ b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jAgentWithToolsIT.java @@ -93,7 +93,7 @@ public class LangChain4jAgentWithToolsIT extends CamelTestSupport { "Use the available tools to provide accurate information."; String userMessage = "Can you tell me the name of user 123 and the weather in New York?"; - AiAgentBody aiAgentBody = new AiAgentBody(systemMessage, userMessage, null); + AiAgentBody<?> aiAgentBody = new AiAgentBody<>(systemMessage, userMessage, null); String response = template.requestBody( "direct:agent-with-multiple-tools", diff --git a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jSimpleAgentIT.java b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jSimpleAgentIT.java index 471ca255e13..da91cd023f3 100644 --- a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jSimpleAgentIT.java +++ b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/integration/LangChain4jSimpleAgentIT.java @@ -88,7 +88,7 @@ public class LangChain4jSimpleAgentIT extends CamelTestSupport { MockEndpoint mockEndpoint = this.context.getEndpoint("mock:response", MockEndpoint.class); mockEndpoint.expectedMessageCount(1); - AiAgentBody body = new AiAgentBody() + AiAgentBody<?> body = new AiAgentBody<>() .withSystemMessage(TEST_SYSTEM_MESSAGE) .withUserMessage(TEST_USER_MESSAGE_STORY);
