fix: Fix issues in unified examples
- Add smart path detection for data directory - Fix add_texts -> add_text method call - Handle both running from project root and examples directory
This commit is contained in:
@@ -164,7 +164,8 @@ class BaseRAGExample(ABC):
|
||||
batch_size = 1000
|
||||
for i in range(0, len(texts), batch_size):
|
||||
batch = texts[i : i + batch_size]
|
||||
builder.add_texts(batch)
|
||||
for text in batch:
|
||||
builder.add_text(text)
|
||||
print(f"Added {min(i + batch_size, len(texts))}/{len(texts)} texts...")
|
||||
|
||||
print("Building index structure...")
|
||||
|
||||
@@ -26,11 +26,17 @@ class DocumentRAG(BaseRAGExample):
|
||||
def _add_specific_arguments(self, parser):
|
||||
"""Add document-specific arguments."""
|
||||
doc_group = parser.add_argument_group("Document Parameters")
|
||||
|
||||
# Smart default path detection
|
||||
default_data_dir = Path("examples/data")
|
||||
if not default_data_dir.exists() and Path("data").exists():
|
||||
default_data_dir = Path("data")
|
||||
|
||||
doc_group.add_argument(
|
||||
"--data-dir",
|
||||
type=str,
|
||||
default="examples/data",
|
||||
help="Directory containing documents to index (default: examples/data)",
|
||||
default=str(default_data_dir),
|
||||
help=f"Directory containing documents to index (default: {default_data_dir})",
|
||||
)
|
||||
doc_group.add_argument(
|
||||
"--file-types",
|
||||
|
||||
Reference in New Issue
Block a user