upd readme mail application
This commit is contained in:
62
README.md
62
README.md
@@ -198,6 +198,68 @@ Once the index is built, you can ask questions like:
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
### 🌐 Lightweight RAG on your Google Chrome History
|
||||||
|
|
||||||
|
LEANN can create a searchable index of your Chrome browser history, allowing you to query your browsing history using natural language.
|
||||||
|
|
||||||
|
#### Quick Start
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>📋 Click to expand: Command Examples</strong></summary>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Use default Chrome profile (auto-finds all profiles) and recommand method to run this because usually default file is enough
|
||||||
|
python examples/google_history_reader_leann.py
|
||||||
|
|
||||||
|
|
||||||
|
# Run with custom index directory
|
||||||
|
python examples/google_history_reader_leann.py --index-dir "./my_chrome_index"
|
||||||
|
|
||||||
|
# Limit number of history entries processed (useful for testing)
|
||||||
|
python examples/google_history_reader_leann.py --max-entries 500
|
||||||
|
|
||||||
|
# Run a single query
|
||||||
|
python examples/google_history_reader_leann.py --query "What websites did I visit about machine learning?"
|
||||||
|
|
||||||
|
# Use only a specific profile (disable auto-find)
|
||||||
|
python examples/google_history_reader_leann.py --chrome-profile "~/Library/Application Support/Google/Chrome/Default" --no-auto-find-profiles
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
#### Finding Your Chrome Profile
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>🔍 Click to expand: How to find your Chrome profile</strong></summary>
|
||||||
|
|
||||||
|
The default Chrome profile path is configured for a typical macOS setup. If you need to find your specific Chrome profile:
|
||||||
|
|
||||||
|
1. Open Terminal
|
||||||
|
2. Run: `ls ~/Library/Application\ Support/Google/Chrome/`
|
||||||
|
3. Look for folders like "Default", "Profile 1", "Profile 2", etc.
|
||||||
|
4. Use the full path as your `--chrome-profile` argument
|
||||||
|
|
||||||
|
**Common Chrome profile locations:**
|
||||||
|
- macOS: `~/Library/Application Support/Google/Chrome/Default`
|
||||||
|
- Linux: `~/.config/google-chrome/Default`
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
#### Example Queries
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>💬 Click to expand: Example queries you can try</strong></summary>
|
||||||
|
|
||||||
|
Once the index is built, you can ask questions like:
|
||||||
|
- "What websites did I visit about machine learning?"
|
||||||
|
- "Find my search history about programming"
|
||||||
|
- "What YouTube videos did I watch recently?"
|
||||||
|
- "Show me websites I visited about travel planning"
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 📊 Benchmarks
|
## 📊 Benchmarks
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import argparse
|
||||||
try:
|
try:
|
||||||
import dotenv
|
import dotenv
|
||||||
dotenv.load_dotenv()
|
dotenv.load_dotenv()
|
||||||
@@ -13,6 +14,9 @@ from llama_index.core.node_parser import SentenceSplitter
|
|||||||
|
|
||||||
# dotenv.load_dotenv() # handled above if python-dotenv is available
|
# dotenv.load_dotenv() # handled above if python-dotenv is available
|
||||||
|
|
||||||
|
# Default Chrome profile path
|
||||||
|
DEFAULT_CHROME_PROFILE = os.path.expanduser("~/Library/Application Support/Google/Chrome/Default")
|
||||||
|
|
||||||
def create_leann_index_from_multiple_chrome_profiles(profile_dirs: List[Path], index_path: str = "chrome_history_index.leann", max_count: int = -1):
|
def create_leann_index_from_multiple_chrome_profiles(profile_dirs: List[Path], index_path: str = "chrome_history_index.leann", max_count: int = -1):
|
||||||
"""
|
"""
|
||||||
Create LEANN index from multiple Chrome profile data sources.
|
Create LEANN index from multiple Chrome profile data sources.
|
||||||
@@ -217,32 +221,63 @@ async def query_leann_index(index_path: str, query: str):
|
|||||||
print(f"Leann: {chat_response}")
|
print(f"Leann: {chat_response}")
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
# Default Chrome profile path
|
# Parse command line arguments
|
||||||
default_chrome_profile = os.path.expanduser("~/Library/Application Support/Google/Chrome/Default")
|
parser = argparse.ArgumentParser(description='LEANN Chrome History Reader - Create and query browser history index')
|
||||||
|
parser.add_argument('--chrome-profile', type=str, default=DEFAULT_CHROME_PROFILE,
|
||||||
|
help=f'Path to Chrome profile directory (default: {DEFAULT_CHROME_PROFILE}), usually you dont need to change this')
|
||||||
|
parser.add_argument('--index-dir', type=str, default="./chrome_history_index_leann_test",
|
||||||
|
help='Directory to store the LEANN index (default: ./chrome_history_index_leann_test)')
|
||||||
|
parser.add_argument('--max-entries', type=int, default=1000,
|
||||||
|
help='Maximum number of history entries to process (default: 1000)')
|
||||||
|
parser.add_argument('--query', type=str, default=None,
|
||||||
|
help='Single query to run (default: runs example queries)')
|
||||||
|
parser.add_argument('--auto-find-profiles', action='store_true', default=True,
|
||||||
|
help='Automatically find all Chrome profiles (default: True)')
|
||||||
|
|
||||||
INDEX_DIR = Path("./chrome_history_index_leann_test")
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
INDEX_DIR = Path(args.index_dir)
|
||||||
INDEX_PATH = str(INDEX_DIR / "chrome_history.leann")
|
INDEX_PATH = str(INDEX_DIR / "chrome_history.leann")
|
||||||
|
|
||||||
# Find all Chrome profile directories
|
print(f"Using Chrome profile: {args.chrome_profile}")
|
||||||
from history_data.history import ChromeHistoryReader
|
print(f"Index directory: {INDEX_DIR}")
|
||||||
profile_dirs = ChromeHistoryReader.find_chrome_profiles()
|
print(f"Max entries: {args.max_entries}")
|
||||||
|
|
||||||
if not profile_dirs:
|
# Find Chrome profile directories
|
||||||
print("No Chrome profiles found. Exiting.")
|
from history_data.history import ChromeHistoryReader
|
||||||
return
|
|
||||||
|
if args.auto_find_profiles:
|
||||||
|
profile_dirs = ChromeHistoryReader.find_chrome_profiles()
|
||||||
|
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
|
# Create or load the LEANN index from all sources
|
||||||
index_path = create_leann_index_from_multiple_chrome_profiles(profile_dirs, INDEX_PATH,1000)
|
index_path = create_leann_index_from_multiple_chrome_profiles(profile_dirs, INDEX_PATH, args.max_entries)
|
||||||
|
|
||||||
if index_path:
|
if index_path:
|
||||||
# Example queries
|
if args.query:
|
||||||
queries = [
|
# Run single query
|
||||||
"What websites did I visit about machine learning?",
|
await query_leann_index(index_path, args.query)
|
||||||
]
|
else:
|
||||||
|
# Example queries
|
||||||
for query in queries:
|
queries = [
|
||||||
print("\n" + "="*60)
|
"What websites did I visit about machine learning?",
|
||||||
await query_leann_index(index_path, query)
|
"Show me my recent shopping history",
|
||||||
|
"What news sites did I visit this week?",
|
||||||
|
"Find my search history about programming"
|
||||||
|
]
|
||||||
|
|
||||||
|
for query in queries:
|
||||||
|
print("\n" + "="*60)
|
||||||
|
await query_leann_index(index_path, query)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
Reference in New Issue
Block a user