davsclaus commented on code in PR #26566:
URL: https://github.com/apache/camel/pull/26566#discussion_r4041015620


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocs.java:
##########
@@ -1084,15 +1084,29 @@ private static void addLanguageFunctions(JsonObject 
result, LanguageModel model,
         if (functions != null && !functions.isEmpty()) {
             result.put("functionCount", functions.size());
             if (filter != null) {
+                // a group name is that group and nothing else (date is two 
functions, not every function whose
+                // description mentions a date); a function name comes first; 
the rest is a word match
+                boolean group = functions.stream().anyMatch(fn -> 
filter.equalsIgnoreCase(fn.getGroup()));

Review Comment:
   Group mode short-circuits before `isFunctionName` runs, so a filter that is 
both a group name and a function name loses the function. The simple catalog 
has exactly that case today: `bodyOneLine` is declared with `label = 
"function"` in `SimpleConstants.java` (a stray label — its siblings 
`body`/`bodyAs` are `core`), which gives the catalog a phantom group `function` 
with that single entry. The no-filter answer lists that group, so a model that 
follows the hint and asks `optionsFilter=function` gets `bodyOneLine` only, 
while `function(name,exp)` (group `core`) — the one it almost certainly wanted 
— disappears. Before this PR the substring match returned both.
   
   Suggest doing both:
   - check the exact function name before the group short-circuit, so an exact 
name always lands in `exact` and the group filter applies to the rest (`date` 
still works since `date(command)` is in the date group);
   - change `label = "function"` to `"core"` on `BODY_ONE_LINE` and regenerate 
the catalog so the phantom group goes away (here or in a follow-up).



-- 
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]

Reply via email to