-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
66 lines (53 loc) · 2.02 KB
/
Copy pathexample_usage.py
File metadata and controls
66 lines (53 loc) · 2.02 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
#!/usr/bin/env python3
"""
Simple example usage of the Local AI File Manager
"""
from local_ai_system import LocalAIFileManager
from pathlib import Path
def main():
"""Example usage of the Local AI File Manager"""
print("🤖 Local AI File Manager - Example Usage")
print("=" * 50)
# Initialize the AI manager
ai_manager = LocalAIFileManager(
base_directory="./example_data",
model_name="llama3.1:8b"
)
# Example 1: Scan a directory
print("\\n1. Scanning directory...")
home_dir = str(Path.home() / "Documents")
files = ai_manager.scan_directory(home_dir, include_system_files=False)
print(f"Found {len(files)} files")
# Example 2: Process documents
print("\\n2. Processing documents...")
processable_files = [f['path'] for f in files if f['is_processable']][:10] # Limit to 10
if processable_files:
success = ai_manager.process_documents(processable_files)
if success:
print(f"Successfully processed {len(processable_files)} files")
else:
print("Failed to process files")
# Example 3: Query documents
print("\\n3. Querying documents...")
queries = [
"What types of documents do I have?",
"Summarize the content of my files",
"Find any Python or code files"
]
for query in queries:
print(f"\\nQuery: {query}")
result = ai_manager.query_documents(query)
if isinstance(result, dict):
print(f"Answer: {result['answer'][:200]}...")
else:
print(f"Result: {result}")
# Example 4: File organization
print("\\n4. Organizing files...")
analysis = ai_manager.optimize_storage(home_dir)
print(f"Storage Analysis:")
print(f"- Total files: {analysis['total_files']}")
print(f"- Total size: {analysis['total_size'] / 1024 / 1024:.1f} MB")
print(f"- Duplicates found: {analysis['duplicates']}")
print("\\n🎉 Example complete!")
if __name__ == "__main__":
main()