-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
91 lines (72 loc) · 2.51 KB
/
Copy pathexample.py
File metadata and controls
91 lines (72 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python3
"""Example usage of the bucket system."""
import asyncio
import sys
from pathlib import Path
# Add the current directory to Python path
sys.path.insert(0, str(Path(__file__).parent))
from bucket.core import create_bucket
from bucket.models import ArticlePriority
async def main():
"""Example usage of the bucket system."""
print("🪣 Bucket System Example")
print("=" * 40)
# Create bucket instance
bucket = await create_bucket(
db_path="example_bucket.db",
output_dir="example_output",
summarizer_type="mock" # Use mock for testing
)
try:
# Add some example URLs
urls = [
"https://httpbin.org/html",
"https://example.com",
]
print("\n📥 Adding URLs to bucket...")
for url in urls:
article = await bucket.add_url(
url=url,
priority=ArticlePriority.MEDIUM,
tags=["example", "demo"]
)
if article:
print(f"✅ Added: {article.title}")
print(f" Reading time: {article.reading_time} minutes")
print(f" Word count: {article.word_count}")
else:
print(f"❌ Failed to add: {url}")
# Add an RSS feed
print("\n📡 Adding RSS feed...")
success = await bucket.add_feed(
name="Example Feed",
url="https://httpbin.org/xml",
tags=["rss", "example"]
)
if success:
print("✅ RSS feed added")
else:
print("❌ Failed to add RSS feed")
# Generate a briefing
print("\n📄 Generating briefing...")
pdf_path = await bucket.generate_briefing(
title="Example Briefing",
days_back=7,
tags=["example"]
)
if pdf_path:
print(f"✅ Briefing generated: {pdf_path}")
else:
print("❌ Failed to generate briefing")
# Show system status
print("\n📊 System Status:")
print(f" Database: {bucket.db_path}")
print(f" Output directory: {bucket.output_dir}")
print(f" Summarizer: {bucket.summarizer.model_name}")
print("\n🎉 Example completed successfully!")
except Exception as e:
print(f"❌ Error in example: {e}")
finally:
await bucket.close()
if __name__ == "__main__":
asyncio.run(main())