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 741efded72b CAMEL-22405: cleanup the API
741efded72b is described below
commit 741efded72b180435b7b7cebca7d2414ce531c9b
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Sep 8 17:18:28 2025 +0200
CAMEL-22405: cleanup the API
---
.../apache/camel/component/langchain4j/agent/api/Agent.java | 10 +++++-----
.../component/langchain4j/agent/LangChain4jAgentProducer.java | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git
a/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/Agent.java
b/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/Agent.java
index 8df5577e954..ac1e006787d 100644
---
a/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/Agent.java
+++
b/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/Agent.java
@@ -88,9 +88,9 @@ public interface Agent {
* @throws InvalidPayloadRuntimeException if the payload is neither an
{@link AiAgentBody} nor a {@link String}
* @throws Exception if any other error occurs during
payload processing
*/
- default AiAgentBody processBody(Object messagePayload, Exchange exchange)
throws Exception {
- if (messagePayload instanceof AiAgentBody) {
- return (AiAgentBody) messagePayload;
+ default AiAgentBody<?> processBody(Object messagePayload, Exchange
exchange) throws Exception {
+ if (messagePayload instanceof AiAgentBody<?> payload) {
+ return payload;
}
if (!(messagePayload instanceof String)) {
@@ -100,7 +100,7 @@ public interface Agent {
String systemMessage = exchange.getIn().getHeader(SYSTEM_MESSAGE,
String.class);
Object memoryId = exchange.getIn().getHeader(MEMORY_ID);
- return new AiAgentBody((String) messagePayload, systemMessage,
memoryId);
+ return new AiAgentBody<>((String) messagePayload, systemMessage,
memoryId);
}
/**
@@ -120,6 +120,6 @@ public interface Agent {
* @throws RuntimeException if the chat interaction fails due to model
errors, configuration issues, or tool
* execution failures
*/
- String chat(AiAgentBody aiAgentBody, ToolProvider toolProvider);
+ String chat(AiAgentBody<?> aiAgentBody, ToolProvider toolProvider);
}
diff --git
a/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
b/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
index 09537d4d7bc..a11193191e5 100644
---
a/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
+++
b/components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentProducer.java
@@ -64,7 +64,7 @@ public class LangChain4jAgentProducer extends DefaultProducer
{
agent = endpoint.getConfiguration().getAgent();
}
- AiAgentBody aiAgentBody = agent.processBody(messagePayload, exchange);
+ AiAgentBody<?> aiAgentBody = agent.processBody(messagePayload,
exchange);
ToolProvider toolProvider = createCamelToolProvider(tags, exchange);
String response = agent.chat(aiAgentBody, toolProvider);