Skip to content

Commit 95d7acb

Browse files
committed
fix: return number of documents indexed in index_directory
1 parent 5e5ecf2 commit 95d7acb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gptme_rag/indexing/indexer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def add_documents(self, documents: list[Document], batch_size: int = 100) -> Non
147147
f"Indexed {processed}/{total_docs} documents ({progress:.1f}%)"
148148
)
149149

150-
def index_directory(self, directory: Path, glob_pattern: str = "**/*.*") -> None:
150+
def index_directory(self, directory: Path, glob_pattern: str = "**/*.*") -> int:
151151
"""Index all files in a directory matching the glob pattern."""
152152
directory = directory.resolve() # Convert to absolute path
153153
files = list(directory.glob(glob_pattern))
@@ -169,7 +169,7 @@ def index_directory(self, directory: Path, glob_pattern: str = "**/*.*") -> None
169169
logger.debug(
170170
f"No valid documents found in {directory} with pattern {glob_pattern}"
171171
)
172-
return
172+
return 0
173173

174174
# Process files in batches to manage memory
175175
batch_size = 100
@@ -187,6 +187,8 @@ def index_directory(self, directory: Path, glob_pattern: str = "**/*.*") -> None
187187
if current_batch:
188188
self.add_documents(current_batch)
189189

190+
return len(valid_files)
191+
190192
def search(
191193
self,
192194
query: str,

0 commit comments

Comments
 (0)