I'm using LangChain4j to define prompts using @UserMessage annotations, like this:
@UserMessage( "The alert is described as follows: {{description}}\n\n" + "HTTP response evidence:\n---\n{{evidence}}\n---\n" + "Additional context:\n---\n{{otherinfo}}") Confidence review(@V("description") String description, @V("evidence") String evidence, @V("otherinfo") String otherinfo); The problem: if otherinfo is null, the placeholder {{otherinfo}} is still rendered as the string "null" in the final prompt, which confuses the LLM. I want the otherinfo section to be excluded entirely if it's null or empty.
Is there a built-in way in LangChain4j to make prompt sections conditional based on variable values (e.g., skip {{otherinfo}} if it's null)? Or do I need to construct the prompt manually outside the annotation system?
Any advice or best practices appreciated.