feat: add --use-existing-index option to google_history_reader_leann.py
- Allow using existing index without rebuilding - Useful for testing pre-built indices
This commit is contained in:
@@ -298,6 +298,11 @@ async def main():
|
|||||||
choices=["sentence-transformers", "openai", "mlx"],
|
choices=["sentence-transformers", "openai", "mlx"],
|
||||||
help="The embedding backend mode",
|
help="The embedding backend mode",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--use-existing-index",
|
||||||
|
action="store_true",
|
||||||
|
help="Use existing index without rebuilding",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -308,26 +313,34 @@ async def main():
|
|||||||
print(f"Index directory: {INDEX_DIR}")
|
print(f"Index directory: {INDEX_DIR}")
|
||||||
print(f"Max entries: {args.max_entries}")
|
print(f"Max entries: {args.max_entries}")
|
||||||
|
|
||||||
# Find Chrome profile directories
|
if args.use_existing_index:
|
||||||
from history_data.history import ChromeHistoryReader
|
# Use existing index without rebuilding
|
||||||
|
if not Path(INDEX_PATH).exists():
|
||||||
if args.auto_find_profiles:
|
print(f"Error: Index file not found at {INDEX_PATH}")
|
||||||
profile_dirs = ChromeHistoryReader.find_chrome_profiles()
|
|
||||||
if not profile_dirs:
|
|
||||||
print("No Chrome profiles found automatically. Exiting.")
|
|
||||||
return
|
return
|
||||||
|
print(f"Using existing index at {INDEX_PATH}")
|
||||||
|
index_path = INDEX_PATH
|
||||||
else:
|
else:
|
||||||
# Use single specified profile
|
# Find Chrome profile directories
|
||||||
profile_path = Path(args.chrome_profile)
|
from history_data.history import ChromeHistoryReader
|
||||||
if not profile_path.exists():
|
|
||||||
print(f"Chrome profile not found: {profile_path}")
|
|
||||||
return
|
|
||||||
profile_dirs = [profile_path]
|
|
||||||
|
|
||||||
# Create or load the LEANN index from all sources
|
if args.auto_find_profiles:
|
||||||
index_path = create_leann_index_from_multiple_chrome_profiles(
|
profile_dirs = ChromeHistoryReader.find_chrome_profiles()
|
||||||
profile_dirs, INDEX_PATH, args.max_entries, args.embedding_model, args.embedding_mode
|
if not profile_dirs:
|
||||||
)
|
print("No Chrome profiles found automatically. Exiting.")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# Use single specified profile
|
||||||
|
profile_path = Path(args.chrome_profile)
|
||||||
|
if not profile_path.exists():
|
||||||
|
print(f"Chrome profile not found: {profile_path}")
|
||||||
|
return
|
||||||
|
profile_dirs = [profile_path]
|
||||||
|
|
||||||
|
# Create or load the LEANN index from all sources
|
||||||
|
index_path = create_leann_index_from_multiple_chrome_profiles(
|
||||||
|
profile_dirs, INDEX_PATH, args.max_entries, args.embedding_model, args.embedding_mode
|
||||||
|
)
|
||||||
|
|
||||||
if index_path:
|
if index_path:
|
||||||
if args.query:
|
if args.query:
|
||||||
|
|||||||
Reference in New Issue
Block a user