[ https://issues.apache.org/jira/browse/CAMEL-21594?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Zineb Bendhiba updated CAMEL-21594: ----------------------------------- Description: There's a bug in Camel Langchain4j Tools. If the LLM doesn't require using one of the tools provided in the prompt, there's an error. {code:java} : java.lang.NullPointerException: Cannot invoke "dev.langchain4j.model.output.Response.content()" because "response" is null at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.chatWithLLMForToolCalling(LangChain4jToolsProducer.java:110) at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.toolsChat(LangChain4jToolsProducer.java:105) at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.processMultipleMessages(LangChain4jToolsProducer.java:62) at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.process(LangChain4jToolsProducer.java:55) at org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:65) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:208) {code} was: There's a bug in Camel Langchain4j Tools. If the LLM doesn't require using one of the tools provided in the prompt, there's an error. {code:java} : org.apache.camel.RuntimeCamelException: There are no tools to be executed at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.chatWithLLMForTools(LangChain4jToolsProducer.java:148) at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.toolsChat(LangChain4jToolsProducer.java:98) at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.processMultipleMessages(LangChain4jToolsProducer.java:62) at org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.process(LangChain4jToolsProducer.java:56) at org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:65) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:208){code} It seems that the component expects the LLM to ask for a tool as a requirement. In RAG, we should send the list the tools to the LLM, but the LLM would evaluate and ask execution, only if that is relevant. If LLM doesn't ask a tool execution, the component should behave as simple Langchain4j chat component. > Camel Langchain4j Tools bug where no need to execute a tool > ----------------------------------------------------------- > > Key: CAMEL-21594 > URL: https://issues.apache.org/jira/browse/CAMEL-21594 > Project: Camel > Issue Type: Bug > Components: Camel langchain4j Tools > Affects Versions: 4.8.2, 4.9.0 > Reporter: Zineb Bendhiba > Priority: Major > > There's a bug in Camel Langchain4j Tools. > If the LLM doesn't require using one of the tools provided in the prompt, > there's an error. > {code:java} > : java.lang.NullPointerException: Cannot invoke > "dev.langchain4j.model.output.Response.content()" because "response" is null > at > org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.chatWithLLMForToolCalling(LangChain4jToolsProducer.java:110) > at > org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.toolsChat(LangChain4jToolsProducer.java:105) > at > org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.processMultipleMessages(LangChain4jToolsProducer.java:62) > at > org.apache.camel.component.langchain4j.tools.LangChain4jToolsProducer.process(LangChain4jToolsProducer.java:55) > at > org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:65) > at > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:208) > {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)