From 8d2fee5d4559d030b53575d377a0013e2c67b9fe Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 23 Jul 2026 22:35:54 -0400 Subject: [PATCH] refac --- backend/open_webui/tools/knowledge_fs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/open_webui/tools/knowledge_fs.py b/backend/open_webui/tools/knowledge_fs.py index 44d092e792..01026af470 100644 --- a/backend/open_webui/tools/knowledge_fs.py +++ b/backend/open_webui/tools/knowledge_fs.py @@ -691,6 +691,10 @@ async def _kb_grep( for i, line in enumerate(lines, 1): if _matches(line): matched.append(f'{i}: {line}') + if count_only: + return str(len(matched)) + if filenames_only: + return '(standard input)' if matched else f'No matches for "{pattern}"' return '\n'.join(matched) if matched else f'No matches for "{pattern}"' # Single file grep