|
1 | 1 | import os
|
2 | 2 | from fnmatch import fnmatch
|
3 |
| -from typing import Dict, List, Set |
| 3 | +from typing import Any, Dict, List, Optional, Set, Tuple |
4 | 4 |
|
5 | 5 | import tiktoken
|
6 | 6 |
|
@@ -335,10 +335,10 @@ def generate_token_string(context_string: str) -> Optional[str]:
|
335 | 335 | print(e)
|
336 | 336 | return None
|
337 | 337 |
|
338 |
| - if total_tokens > 1000000: |
339 |
| - formatted_tokens = f"{total_tokens/1000000:.1f}M" |
340 |
| - elif total_tokens > 1000: |
341 |
| - formatted_tokens = f"{total_tokens/1000:.1f}k" |
| 338 | + if total_tokens > 1_000_000: |
| 339 | + formatted_tokens = f"{total_tokens / 1_000_000:.1f}M" |
| 340 | + elif total_tokens > 1_000: |
| 341 | + formatted_tokens = f"{total_tokens / 1_000:.1f}k" |
342 | 342 | else:
|
343 | 343 | formatted_tokens = f"{total_tokens}"
|
344 | 344 |
|
@@ -383,6 +383,8 @@ def ingest_single_file(path: str, query: Dict[str, Any]) -> Tuple[str, str, str]
|
383 | 383 |
|
384 | 384 | def ingest_directory(path: str, query: Dict[str, Any]) -> Tuple[str, str, str]:
|
385 | 385 | nodes = scan_directory(path=path, query=query)
|
| 386 | + if not nodes: |
| 387 | + raise ValueError(f"No files found in {path}") |
386 | 388 | files = extract_files_content(query=query, node=nodes, max_file_size=query['max_file_size'])
|
387 | 389 | summary = create_summary_string(query, nodes, files)
|
388 | 390 | tree = "Directory structure:\n" + create_tree_structure(query, nodes)
|
|
0 commit comments