claude-self-reflect 2.3.6 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Quick import of current conversation using Voyage AI"""
3
-
4
- import os
5
- import sys
6
- sys.path.append(os.path.dirname(os.path.abspath(__file__)))
7
-
8
- import importlib.util
9
- spec = importlib.util.spec_from_file_location("voyage_importer",
10
- os.path.join(os.path.dirname(__file__), "import-conversations-voyage.py"))
11
- voyage_module = importlib.util.module_from_spec(spec)
12
- spec.loader.exec_module(voyage_module)
13
- VoyageConversationImporter = voyage_module.VoyageConversationImporter
14
-
15
- def main():
16
- # Import just the current conversation
17
- importer = VoyageConversationImporter()
18
-
19
- # Example: Update these to your project path and file
20
- project_path = os.path.expanduser("~/.claude/projects/your-project-name")
21
- target_file = "your-conversation-id.jsonl"
22
-
23
- print(f"Importing current conversation: {target_file}")
24
-
25
- # Process just this file
26
- file_path = os.path.join(project_path, target_file)
27
- if os.path.exists(file_path):
28
- chunks = importer.process_jsonl_file(file_path)
29
- if chunks:
30
- collection_name = importer.get_collection_name(os.path.basename(project_path))
31
- importer.import_chunks(chunks, collection_name)
32
- print(f"✅ Imported {len(chunks)} chunks from current conversation")
33
- else:
34
- print("❌ No chunks found in current conversation")
35
- else:
36
- print(f"❌ File not found: {file_path}")
37
-
38
- if __name__ == "__main__":
39
- main()
@@ -1,154 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Import the currently active conversation file."""
3
-
4
- import os
5
- import sys
6
- import json
7
- import hashlib
8
- from datetime import datetime, timedelta
9
- from qdrant_client import QdrantClient
10
- from qdrant_client.models import PointStruct, VectorParams, Distance
11
- import backoff
12
- import requests
13
-
14
- # Configuration
15
- QDRANT_URL = "http://localhost:6333"
16
- VOYAGE_API_KEY = os.getenv("VOYAGE_KEY")
17
- VOYAGE_API_URL = "https://api.voyageai.com/v1/embeddings"
18
-
19
- @backoff.on_exception(backoff.expo, Exception, max_tries=3)
20
- def generate_embedding(text):
21
- """Generate embedding using Voyage AI."""
22
- headers = {
23
- "Authorization": f"Bearer {VOYAGE_API_KEY}",
24
- "Content-Type": "application/json"
25
- }
26
-
27
- response = requests.post(
28
- VOYAGE_API_URL,
29
- headers=headers,
30
- json={
31
- "input": [text],
32
- "model": "voyage-3-large"
33
- }
34
- )
35
-
36
- if response.status_code != 200:
37
- raise Exception(f"Voyage API error: {response.status_code} - {response.text}")
38
-
39
- return response.json()["data"][0]["embedding"]
40
-
41
- def import_conversation(file_path):
42
- """Import a single conversation file."""
43
- client = QdrantClient(url=QDRANT_URL)
44
-
45
- # Determine collection name
46
- # Example: Update to your project path
47
- project_path = os.path.expanduser("~/your-project-path")
48
- project_hash = hashlib.md5(project_path.encode()).hexdigest()[:8]
49
- collection_name = f"conv_{project_hash}_voyage"
50
-
51
- print(f"Importing to collection: {collection_name}")
52
-
53
- # Ensure collection exists
54
- collections = [c.name for c in client.get_collections().collections]
55
- if collection_name not in collections:
56
- client.create_collection(
57
- collection_name=collection_name,
58
- vectors_config=VectorParams(size=1024, distance=Distance.COSINE)
59
- )
60
-
61
- # Read recent messages (last 2 hours)
62
- from datetime import timezone
63
- cutoff = datetime.now(timezone.utc) - timedelta(hours=2)
64
- points_to_import = []
65
-
66
- with open(file_path, 'r') as f:
67
- for line in f:
68
- try:
69
- entry = json.loads(line)
70
- timestamp_str = entry.get('timestamp', '')
71
-
72
- # Parse timestamp
73
- if timestamp_str:
74
- # Convert ISO format to datetime
75
- timestamp = datetime.fromisoformat(timestamp_str.replace('Z', '+00:00'))
76
-
77
- # Only import recent entries
78
- if timestamp > cutoff:
79
- # Extract message content
80
- message = entry.get('message', {})
81
- content = message.get('content', [])
82
-
83
- # Extract text from content
84
- text_parts = []
85
- for item in content:
86
- if isinstance(item, dict) and item.get('type') == 'text':
87
- text_parts.append(item.get('text', ''))
88
-
89
- if text_parts:
90
- text = ' '.join(text_parts)
91
-
92
- # Create unique ID
93
- point_id = hashlib.md5(f"{entry.get('uuid', '')}_{timestamp_str}".encode()).hexdigest()
94
-
95
- # Generate embedding
96
- print(f"Generating embedding for entry from {timestamp_str[:19]}")
97
- try:
98
- embedding = generate_embedding(text[:8000]) # Limit text length
99
-
100
- points_to_import.append(
101
- PointStruct(
102
- id=point_id,
103
- vector=embedding,
104
- payload={
105
- "text": text[:2000],
106
- "timestamp": timestamp.timestamp(),
107
- "role": message.get('role', 'unknown'),
108
- "conversation_id": entry.get('sessionId', ''),
109
- "project": project_path
110
- }
111
- )
112
- )
113
-
114
- # Import in batches
115
- if len(points_to_import) >= 10:
116
- client.upsert(
117
- collection_name=collection_name,
118
- points=points_to_import
119
- )
120
- print(f"Imported batch of {len(points_to_import)} points")
121
- points_to_import = []
122
-
123
- except Exception as e:
124
- print(f"Error generating embedding: {e}")
125
-
126
- except json.JSONDecodeError:
127
- continue
128
-
129
- # Import remaining points
130
- if points_to_import:
131
- client.upsert(
132
- collection_name=collection_name,
133
- points=points_to_import
134
- )
135
- print(f"Imported final batch of {len(points_to_import)} points")
136
-
137
- # Check collection status
138
- info = client.get_collection(collection_name)
139
- print(f"\nCollection {collection_name} now has {info.points_count} points")
140
-
141
- def main():
142
- # Example: Update to your conversation file path
143
- file_path = os.path.expanduser("~/.claude/projects/your-project/your-conversation-id.jsonl")
144
-
145
- if not os.path.exists(file_path):
146
- print(f"File not found: {file_path}")
147
- return
148
-
149
- print(f"Importing live conversation from: {file_path}")
150
- import_conversation(file_path)
151
- print("\nImport complete!")
152
-
153
- if __name__ == "__main__":
154
- main()