chandru9 commented on code in PR #21704:
URL: https://github.com/apache/camel/pull/21704#discussion_r2899529901
##########
components/camel-ai/camel-langchain4j-agent/src/main/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentConverter.java:
##########
@@ -191,10 +197,79 @@ public static AiAgentBody<?>
inputStreamToAiAgentBody(InputStream inputStream, E
}
}
+ /**
+ * Converts a {@link String} to an {@link AiAgentBody} with the
appropriate {@link Content} type.
+ * <p>
+ * This converter is useful for the text components that return Text Body.
+ * </p>
+ *
+ * @param text
+ * @param exchange
+ * @return an AiAgentBody with the appropriate Content type
+ */
+ @Converter
+ public static AiAgentBody<?> textToAiAgentBody(String text, Exchange
exchange) {
+ String userMessage = exchange.getIn().getHeader(USER_MESSAGE,
String.class);
+ String systemMessage = exchange.getIn().getHeader(SYSTEM_MESSAGE,
String.class);
+ Object memoryId = exchange.getIn().getHeader(MEMORY_ID);
+
+ TextContent content = TextContent.from(text);
+
+ AiAgentBody<TextContent> body = new AiAgentBody<>();
+ body.setUserMessage(userMessage != null ? userMessage : text);
+ body.setSystemMessage(systemMessage);
+ body.setMemoryId(memoryId);
+ body.setContent(content);
+ return body;
+ }
+
+ /**
+ * Converts a {@link String} to an {@link AiAgentBody} with the
appropriate {@link Content} type.
Review Comment:
@orpiske: thanks for the comments. support for the BufferedImage type would
be removed. as suggested by @davsclaus and @jamesnetherton. I am currently
adopting the other review comments and push the changes shortly. do you see we
would still use explicit conversion for Buffered Image ?
--
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]