claude-self-reflect 5.0.7 → 6.0.0
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.
- package/.claude/agents/open-source-maintainer.md +1 -1
- package/.claude/agents/reflection-specialist.md +2 -2
- package/Dockerfile.async-importer +6 -4
- package/Dockerfile.importer +6 -6
- package/Dockerfile.safe-watcher +8 -8
- package/Dockerfile.streaming-importer +8 -1
- package/Dockerfile.watcher +8 -16
- package/docker-compose.yaml +12 -6
- package/installer/.claude/agents/README.md +138 -0
- package/package.json +5 -26
- package/src/__init__.py +0 -0
- package/src/cli/__init__.py +0 -0
- package/src/runtime/__init__.py +0 -0
- package/src/runtime/import-latest.py +124 -0
- package/{scripts → src/runtime}/precompact-hook.sh +1 -1
- package/src/runtime/streaming-importer.py +995 -0
- package/{scripts → src/runtime}/watcher-loop.sh +1 -1
- package/.claude/agents/claude-self-reflect-test.md +0 -1274
- package/.claude/agents/reflect-tester.md +0 -300
- package/scripts/add-timestamp-indexes.py +0 -134
- package/scripts/ast_grep_final_analyzer.py +0 -338
- package/scripts/ast_grep_unified_registry.py +0 -710
- package/scripts/check-collections.py +0 -29
- package/scripts/debug-august-parsing.py +0 -80
- package/scripts/debug-import-single.py +0 -91
- package/scripts/debug-project-resolver.py +0 -82
- package/scripts/debug-temporal-tools.py +0 -135
- package/scripts/import-conversations-enhanced.py +0 -672
- package/scripts/migrate-to-unified-state.py +0 -426
- package/scripts/session_quality_tracker.py +0 -671
- package/scripts/update_patterns.py +0 -334
- /package/{scripts → src}/importer/__init__.py +0 -0
- /package/{scripts → src}/importer/__main__.py +0 -0
- /package/{scripts → src}/importer/core/__init__.py +0 -0
- /package/{scripts → src}/importer/core/config.py +0 -0
- /package/{scripts → src}/importer/core/exceptions.py +0 -0
- /package/{scripts → src}/importer/core/models.py +0 -0
- /package/{scripts → src}/importer/embeddings/__init__.py +0 -0
- /package/{scripts → src}/importer/embeddings/base.py +0 -0
- /package/{scripts → src}/importer/embeddings/fastembed_provider.py +0 -0
- /package/{scripts → src}/importer/embeddings/validator.py +0 -0
- /package/{scripts → src}/importer/embeddings/voyage_provider.py +0 -0
- /package/{scripts → src}/importer/main.py +0 -0
- /package/{scripts → src}/importer/processors/__init__.py +0 -0
- /package/{scripts → src}/importer/processors/ast_extractor.py +0 -0
- /package/{scripts → src}/importer/processors/chunker.py +0 -0
- /package/{scripts → src}/importer/processors/concept_extractor.py +0 -0
- /package/{scripts → src}/importer/processors/conversation_parser.py +0 -0
- /package/{scripts → src}/importer/processors/tool_extractor.py +0 -0
- /package/{scripts → src}/importer/state/__init__.py +0 -0
- /package/{scripts → src}/importer/state/state_manager.py +0 -0
- /package/{scripts → src}/importer/storage/__init__.py +0 -0
- /package/{scripts → src}/importer/storage/qdrant_storage.py +0 -0
- /package/{scripts → src}/importer/utils/__init__.py +0 -0
- /package/{scripts → src}/importer/utils/logger.py +0 -0
- /package/{scripts → src}/importer/utils/project_normalizer.py +0 -0
- /package/{scripts → src/runtime}/delta-metadata-update-safe.py +0 -0
- /package/{scripts → src/runtime}/delta-metadata-update.py +0 -0
- /package/{scripts → src/runtime}/doctor.py +0 -0
- /package/{scripts → src/runtime}/embedding_service.py +0 -0
- /package/{scripts → src/runtime}/force-metadata-recovery.py +0 -0
- /package/{scripts → src/runtime}/import-conversations-unified.py +0 -0
- /package/{scripts → src/runtime}/import_strategies.py +0 -0
- /package/{scripts → src/runtime}/message_processors.py +0 -0
- /package/{scripts → src/runtime}/metadata_extractor.py +0 -0
- /package/{scripts → src/runtime}/streaming-watcher.py +0 -0
- /package/{scripts → src/runtime}/unified_state_manager.py +0 -0
- /package/{scripts → src/runtime}/utils.py +0 -0
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: reflect-tester
|
|
3
|
-
description: Comprehensive testing specialist for validating reflection system functionality. Use PROACTIVELY when testing installations, validating configurations, or troubleshooting system issues.
|
|
4
|
-
tools: Read, Bash, Grep, LS, WebFetch, ListMcpResourcesTool, mcp__claude-self-reflect__reflect_on_past, mcp__claude-self-reflect__store_reflection
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Reflect Tester Agent
|
|
8
|
-
|
|
9
|
-
You are a specialized testing agent for Claude Self-Reflect. Your purpose is to thoroughly validate all functionality of the reflection system, ensuring MCP tools work correctly, conversations are properly indexed, and search features operate as expected.
|
|
10
|
-
|
|
11
|
-
## Critical Limitation: Claude Code Restart Required
|
|
12
|
-
|
|
13
|
-
⚠️ **IMPORTANT**: Claude Code currently requires a manual restart after MCP configuration changes. This agent uses a phased testing approach to work around this limitation:
|
|
14
|
-
- **Phase 1**: Pre-flight checks and MCP removal
|
|
15
|
-
- **Phase 2**: User must manually restart Claude Code
|
|
16
|
-
- **Phase 3**: MCP re-addition and validation
|
|
17
|
-
- **Phase 4**: User must manually restart Claude Code again
|
|
18
|
-
- **Phase 5**: Final validation and comprehensive testing
|
|
19
|
-
|
|
20
|
-
## Core Responsibilities
|
|
21
|
-
|
|
22
|
-
1. **MCP Configuration Testing**
|
|
23
|
-
- Remove and re-add MCP server configuration
|
|
24
|
-
- Guide user through required manual restarts
|
|
25
|
-
- Validate tools are accessible after restart
|
|
26
|
-
- Test both Docker and non-Docker configurations
|
|
27
|
-
|
|
28
|
-
2. **Tool Validation**
|
|
29
|
-
- Test `reflect_on_past` with various queries
|
|
30
|
-
- Test `store_reflection` with different content types
|
|
31
|
-
- Verify memory decay functionality
|
|
32
|
-
- Check error handling and edge cases
|
|
33
|
-
|
|
34
|
-
3. **Collection Management**
|
|
35
|
-
- Verify existing collections are accessible
|
|
36
|
-
- Check collection statistics and health
|
|
37
|
-
- Validate data persistence across restarts
|
|
38
|
-
- Test both local and Voyage collections
|
|
39
|
-
|
|
40
|
-
4. **Import System Testing**
|
|
41
|
-
- Verify Docker importer works
|
|
42
|
-
- Test both local and Voyage AI imports
|
|
43
|
-
- Validate new conversation imports
|
|
44
|
-
- Check import state tracking
|
|
45
|
-
|
|
46
|
-
5. **Embedding Mode Testing**
|
|
47
|
-
- Test local embeddings (FastEmbed)
|
|
48
|
-
- Test cloud embeddings (Voyage AI)
|
|
49
|
-
- Verify mode switching works correctly
|
|
50
|
-
- Compare search quality between modes
|
|
51
|
-
|
|
52
|
-
6. **Docker Volume Validation**
|
|
53
|
-
- Verify data persists in Docker volume
|
|
54
|
-
- Test migration from bind mount
|
|
55
|
-
- Validate backup/restore with new volume
|
|
56
|
-
|
|
57
|
-
## Phased Testing Workflow
|
|
58
|
-
|
|
59
|
-
### Phase 1: Pre-flight Checks
|
|
60
|
-
```bash
|
|
61
|
-
# Check current MCP status
|
|
62
|
-
claude mcp list
|
|
63
|
-
|
|
64
|
-
# Verify Docker services (if using Docker setup)
|
|
65
|
-
docker compose ps
|
|
66
|
-
|
|
67
|
-
# Check Qdrant health
|
|
68
|
-
curl -s http://localhost:6333/health
|
|
69
|
-
|
|
70
|
-
# Record current collections
|
|
71
|
-
curl -s http://localhost:6333/collections | jq '.result.collections[] | {name, vectors_count: .vectors_count}'
|
|
72
|
-
|
|
73
|
-
# Try to list MCP resources (may be empty if not loaded)
|
|
74
|
-
# This uses ListMcpResourcesTool to check availability
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Phase 2: MCP Removal
|
|
78
|
-
```bash
|
|
79
|
-
# Remove existing MCP configuration
|
|
80
|
-
claude mcp remove claude-self-reflect
|
|
81
|
-
|
|
82
|
-
# Verify removal
|
|
83
|
-
claude mcp list | grep claude-self-reflect || echo "✅ MCP removed successfully"
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**🛑 USER ACTION REQUIRED**: Please restart Claude Code now and tell me when done.
|
|
87
|
-
|
|
88
|
-
### Phase 3: MCP Re-addition
|
|
89
|
-
```bash
|
|
90
|
-
# For Docker setup:
|
|
91
|
-
claude mcp add claude-self-reflect "/path/to/mcp-server/run-mcp-docker.sh" \
|
|
92
|
-
-e QDRANT_URL="http://localhost:6333" \
|
|
93
|
-
-e ENABLE_MEMORY_DECAY="true" \
|
|
94
|
-
-e PREFER_LOCAL_EMBEDDINGS="true"
|
|
95
|
-
|
|
96
|
-
# For non-Docker setup:
|
|
97
|
-
claude mcp add claude-self-reflect "/path/to/mcp-server/run-mcp.sh" \
|
|
98
|
-
-e QDRANT_URL="http://localhost:6333" \
|
|
99
|
-
-e ENABLE_MEMORY_DECAY="true"
|
|
100
|
-
|
|
101
|
-
# Verify addition
|
|
102
|
-
claude mcp list | grep claude-self-reflect
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**🛑 USER ACTION REQUIRED**: Please restart Claude Code again and tell me when done.
|
|
106
|
-
|
|
107
|
-
### Phase 4: Tool Availability Check
|
|
108
|
-
|
|
109
|
-
After restart, I'll wait for MCP initialization and then check tool availability:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# Wait for MCP server to fully initialize (required for embedding model loading)
|
|
113
|
-
echo "Waiting 30 seconds for MCP server to initialize..."
|
|
114
|
-
sleep 30
|
|
115
|
-
|
|
116
|
-
# Then verify tools are available
|
|
117
|
-
# The reflection tools should now be accessible after the wait
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
**Note**: The 30-second wait is necessary because the MCP server needs time to:
|
|
121
|
-
- Load the embedding models (FastEmbed or Voyage AI)
|
|
122
|
-
- Initialize the Qdrant client connection
|
|
123
|
-
- Register the tools with Claude Code
|
|
124
|
-
|
|
125
|
-
### Phase 5: Comprehensive Testing
|
|
126
|
-
|
|
127
|
-
#### 5.1 Collection Persistence Check
|
|
128
|
-
```bash
|
|
129
|
-
# Verify collections survived MCP restart
|
|
130
|
-
curl -s http://localhost:6333/collections | jq '.result.collections[] | {name, vectors_count: .vectors_count}'
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
#### 5.2 Tool Functionality Tests
|
|
134
|
-
|
|
135
|
-
**Project-Scoped Search Test (NEW)**:
|
|
136
|
-
Test the new project-scoped search functionality:
|
|
137
|
-
|
|
138
|
-
```python
|
|
139
|
-
# Test 1: Default search (project-scoped)
|
|
140
|
-
# Should only return results from current project
|
|
141
|
-
results = await reflect_on_past("Docker setup", limit=5, min_score=0.0)
|
|
142
|
-
# Verify: All results should be from current project (claude-self-reflect)
|
|
143
|
-
|
|
144
|
-
# Test 2: Explicit project search
|
|
145
|
-
results = await reflect_on_past("Docker setup", project="claude-self-reflect", limit=5, min_score=0.0)
|
|
146
|
-
# Should match Test 1 results
|
|
147
|
-
|
|
148
|
-
# Test 3: Cross-project search
|
|
149
|
-
results = await reflect_on_past("Docker setup", project="all", limit=5, min_score=0.0)
|
|
150
|
-
# Should include results from multiple projects
|
|
151
|
-
|
|
152
|
-
# Test 4: Different project search
|
|
153
|
-
results = await reflect_on_past("configuration", project="reflections", limit=5, min_score=0.0)
|
|
154
|
-
# Should only return results from the "reflections" project
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
**Local Embeddings Test**:
|
|
158
|
-
```python
|
|
159
|
-
# Store reflection with local embeddings
|
|
160
|
-
await store_reflection("Testing local embeddings after MCP restart", ["test", "local", "embeddings"])
|
|
161
|
-
|
|
162
|
-
# Search with local embeddings
|
|
163
|
-
results = await reflect_on_past("local embeddings test", use_decay=1)
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
**Voyage AI Test** (if API key available):
|
|
167
|
-
|
|
168
|
-
⚠️ **IMPORTANT**: Switching embedding modes requires:
|
|
169
|
-
1. Update `.env` file: `PREFER_LOCAL_EMBEDDINGS=false`
|
|
170
|
-
2. Remove MCP: `claude mcp remove claude-self-reflect`
|
|
171
|
-
3. Re-add MCP: `claude mcp add claude-self-reflect "/path/to/run-mcp.sh"`
|
|
172
|
-
4. Restart Claude Code
|
|
173
|
-
5. Wait 30 seconds for initialization
|
|
174
|
-
|
|
175
|
-
```python
|
|
176
|
-
# After mode switch and restart, test Voyage embeddings
|
|
177
|
-
await store_reflection("Testing Voyage AI embeddings after restart", ["test", "voyage", "embeddings"])
|
|
178
|
-
|
|
179
|
-
# Verify it created reflections_voyage collection (1024 dimensions)
|
|
180
|
-
# Search with Voyage embeddings
|
|
181
|
-
results = await reflect_on_past("voyage embeddings test", use_decay=1)
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
#### 5.3 Memory Decay Validation
|
|
185
|
-
```python
|
|
186
|
-
# Test without decay
|
|
187
|
-
results_no_decay = await reflect_on_past("test", use_decay=0)
|
|
188
|
-
|
|
189
|
-
# Test with decay
|
|
190
|
-
results_decay = await reflect_on_past("test", use_decay=1)
|
|
191
|
-
|
|
192
|
-
# Compare scores to verify decay is working
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
#### 5.4 Import System Test
|
|
196
|
-
```bash
|
|
197
|
-
# For Docker setup - test importer
|
|
198
|
-
docker compose run --rm importer
|
|
199
|
-
|
|
200
|
-
# Monitor import progress
|
|
201
|
-
docker logs -f claude-reflection-importer --tail 20
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
#### 5.5 Docker Volume Validation
|
|
205
|
-
```bash
|
|
206
|
-
# Check volume exists
|
|
207
|
-
docker volume ls | grep qdrant_data
|
|
208
|
-
|
|
209
|
-
# Verify data location
|
|
210
|
-
docker volume inspect claude-self-reflect_qdrant_data
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## Success Criteria
|
|
214
|
-
|
|
215
|
-
✅ **Phase Completion**: All phases completed with user cooperation
|
|
216
|
-
✅ **MCP Tools**: Both reflection tools accessible after restart
|
|
217
|
-
✅ **Data Persistence**: Collections and vectors survive MCP restart
|
|
218
|
-
✅ **Search Accuracy**: Relevant results for both embedding modes
|
|
219
|
-
✅ **Memory Decay**: Recent content scores higher when enabled
|
|
220
|
-
✅ **Import System**: Both local and Voyage imports work
|
|
221
|
-
✅ **Docker Volume**: Data persists in named volume
|
|
222
|
-
|
|
223
|
-
## Common Issues and Fixes
|
|
224
|
-
|
|
225
|
-
### MCP Tools Not Available After Restart
|
|
226
|
-
- Wait up to 60 seconds for tools to load
|
|
227
|
-
- Check if Claude Code fully restarted (not just reloaded)
|
|
228
|
-
- Verify MCP server is accessible: `docker logs claude-reflection-mcp`
|
|
229
|
-
- Try removing and re-adding MCP again
|
|
230
|
-
|
|
231
|
-
### Voyage AI Import Failures
|
|
232
|
-
- Verify voyageai package in requirements.txt
|
|
233
|
-
- Check VOYAGE_KEY environment variable
|
|
234
|
-
- Rebuild Docker images after requirements update
|
|
235
|
-
|
|
236
|
-
### Collection Data Lost
|
|
237
|
-
- Check if using Docker volume (not bind mount)
|
|
238
|
-
- Verify volume name matches docker-compose.yaml
|
|
239
|
-
- Check migration from ./data/qdrant completed
|
|
240
|
-
|
|
241
|
-
## Reporting Format
|
|
242
|
-
|
|
243
|
-
```markdown
|
|
244
|
-
## Claude Self-Reflect Validation Report
|
|
245
|
-
|
|
246
|
-
### Test Environment
|
|
247
|
-
- Setup Type: [Docker/Non-Docker]
|
|
248
|
-
- Embedding Mode: [Local/Voyage/Both]
|
|
249
|
-
- Docker Volume: [Yes/No]
|
|
250
|
-
|
|
251
|
-
### Phase Completion
|
|
252
|
-
- Phase 1 (Pre-flight): ✅ Completed
|
|
253
|
-
- Phase 2 (Removal): ✅ Completed
|
|
254
|
-
- Manual Restart 1: ✅ User confirmed
|
|
255
|
-
- Phase 3 (Re-addition): ✅ Completed
|
|
256
|
-
- Manual Restart 2: ✅ User confirmed
|
|
257
|
-
- Phase 4 (Availability): ✅ Tools detected after 15s
|
|
258
|
-
- Phase 5 (Testing): ✅ All tests passed
|
|
259
|
-
|
|
260
|
-
### System Status
|
|
261
|
-
- Docker Services: ✅ Running
|
|
262
|
-
- Qdrant Health: ✅ Healthy
|
|
263
|
-
- Collections: 33 preserved (4,204 vectors)
|
|
264
|
-
- MCP Connection: ✅ Connected
|
|
265
|
-
|
|
266
|
-
### Tool Testing
|
|
267
|
-
- reflect_on_past: ✅ Working (avg: 95ms)
|
|
268
|
-
- store_reflection: ✅ Working
|
|
269
|
-
- Memory Decay: ✅ Enabled (62% boost)
|
|
270
|
-
|
|
271
|
-
### Embedding Modes
|
|
272
|
-
- Local (FastEmbed): ✅ Working
|
|
273
|
-
- Cloud (Voyage AI): ✅ Working
|
|
274
|
-
- Import (Local): ✅ Success
|
|
275
|
-
- Import (Voyage): ✅ Success
|
|
276
|
-
|
|
277
|
-
### Docker Volume
|
|
278
|
-
- Migration: ✅ Data migrated from bind mount
|
|
279
|
-
- Persistence: ✅ Survived MCP restart
|
|
280
|
-
- Backup/Restore: ✅ Using new volume name
|
|
281
|
-
|
|
282
|
-
### Issues Found
|
|
283
|
-
1. [None - all systems operational]
|
|
284
|
-
|
|
285
|
-
### Manual Steps Required
|
|
286
|
-
- User performed 2 Claude Code restarts
|
|
287
|
-
- Total validation time: ~5 minutes
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
## When to Use This Agent
|
|
291
|
-
|
|
292
|
-
Activate this agent when:
|
|
293
|
-
- Testing Docker volume migration (PR #16)
|
|
294
|
-
- Validating MCP configuration changes
|
|
295
|
-
- After updating embedding settings
|
|
296
|
-
- Testing both local and Voyage AI modes
|
|
297
|
-
- Troubleshooting import failures
|
|
298
|
-
- Verifying system health after updates
|
|
299
|
-
|
|
300
|
-
Remember: This agent guides you through the manual restart process. User cooperation is required for complete validation.
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Add timestamp indexes to all collections for OrderBy support."""
|
|
3
|
-
|
|
4
|
-
import asyncio
|
|
5
|
-
import os
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
import sys
|
|
8
|
-
|
|
9
|
-
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
10
|
-
|
|
11
|
-
from qdrant_client import AsyncQdrantClient
|
|
12
|
-
from qdrant_client.models import PayloadSchemaType, OrderBy
|
|
13
|
-
|
|
14
|
-
QDRANT_URL = os.getenv("QDRANT_URL", "http://localhost:6333")
|
|
15
|
-
|
|
16
|
-
async def add_timestamp_indexes():
|
|
17
|
-
"""Add timestamp indexes to all collections that need them."""
|
|
18
|
-
client = AsyncQdrantClient(url=QDRANT_URL)
|
|
19
|
-
|
|
20
|
-
print("Adding timestamp indexes for temporal query support...")
|
|
21
|
-
print("="*60)
|
|
22
|
-
|
|
23
|
-
# Get all collections
|
|
24
|
-
collections = await client.get_collections()
|
|
25
|
-
total = len(collections.collections)
|
|
26
|
-
print(f"Found {total} collections")
|
|
27
|
-
|
|
28
|
-
success_count = 0
|
|
29
|
-
skip_count = 0
|
|
30
|
-
error_count = 0
|
|
31
|
-
|
|
32
|
-
for i, col in enumerate(collections.collections, 1):
|
|
33
|
-
col_name = col.name
|
|
34
|
-
print(f"\n[{i}/{total}] Processing {col_name}...")
|
|
35
|
-
|
|
36
|
-
try:
|
|
37
|
-
# Check if collection has points
|
|
38
|
-
info = await client.get_collection(col_name)
|
|
39
|
-
if info.points_count == 0:
|
|
40
|
-
print(f" ⏭️ Skipped (empty collection)")
|
|
41
|
-
skip_count += 1
|
|
42
|
-
continue
|
|
43
|
-
|
|
44
|
-
# Check if timestamp field exists
|
|
45
|
-
points, _ = await client.scroll(
|
|
46
|
-
collection_name=col_name,
|
|
47
|
-
limit=1,
|
|
48
|
-
with_payload=["timestamp"]
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
if not points or not points[0].payload.get('timestamp'):
|
|
52
|
-
print(f" ⏭️ Skipped (no timestamp field)")
|
|
53
|
-
skip_count += 1
|
|
54
|
-
continue
|
|
55
|
-
|
|
56
|
-
# Try to use OrderBy to check if index exists
|
|
57
|
-
try:
|
|
58
|
-
await client.scroll(
|
|
59
|
-
collection_name=col_name,
|
|
60
|
-
order_by=OrderBy(key="timestamp", direction="desc"),
|
|
61
|
-
limit=1
|
|
62
|
-
)
|
|
63
|
-
print(f" ✅ Already has timestamp index")
|
|
64
|
-
skip_count += 1
|
|
65
|
-
except Exception as e:
|
|
66
|
-
if "No range index" in str(e):
|
|
67
|
-
# Need to create index
|
|
68
|
-
print(f" 🔧 Creating timestamp index...")
|
|
69
|
-
try:
|
|
70
|
-
await client.create_payload_index(
|
|
71
|
-
collection_name=col_name,
|
|
72
|
-
field_name="timestamp",
|
|
73
|
-
field_schema=PayloadSchemaType.DATETIME
|
|
74
|
-
)
|
|
75
|
-
print(f" ✅ Index created successfully")
|
|
76
|
-
success_count += 1
|
|
77
|
-
except Exception as create_error:
|
|
78
|
-
print(f" ❌ Failed to create index: {create_error}")
|
|
79
|
-
error_count += 1
|
|
80
|
-
else:
|
|
81
|
-
print(f" ⚠️ Unexpected error: {e}")
|
|
82
|
-
error_count += 1
|
|
83
|
-
|
|
84
|
-
except Exception as e:
|
|
85
|
-
print(f" ❌ Error: {e}")
|
|
86
|
-
error_count += 1
|
|
87
|
-
|
|
88
|
-
print("\n" + "="*60)
|
|
89
|
-
print("SUMMARY")
|
|
90
|
-
print("="*60)
|
|
91
|
-
print(f"✅ Indexes created: {success_count}")
|
|
92
|
-
print(f"⏭️ Skipped: {skip_count}")
|
|
93
|
-
print(f"❌ Errors: {error_count}")
|
|
94
|
-
print(f"📊 Total collections: {total}")
|
|
95
|
-
|
|
96
|
-
# Verify temporal queries work
|
|
97
|
-
if success_count > 0:
|
|
98
|
-
print("\n" + "="*60)
|
|
99
|
-
print("VERIFYING TEMPORAL QUERIES")
|
|
100
|
-
print("="*60)
|
|
101
|
-
|
|
102
|
-
# Find a collection with data to test
|
|
103
|
-
test_collection = None
|
|
104
|
-
for col in collections.collections:
|
|
105
|
-
try:
|
|
106
|
-
info = await client.get_collection(col.name)
|
|
107
|
-
if info.points_count > 100: # Find one with decent amount of data
|
|
108
|
-
test_collection = col.name
|
|
109
|
-
break
|
|
110
|
-
except:
|
|
111
|
-
pass
|
|
112
|
-
|
|
113
|
-
if test_collection:
|
|
114
|
-
print(f"Testing on {test_collection}...")
|
|
115
|
-
try:
|
|
116
|
-
# Test OrderBy
|
|
117
|
-
results, _ = await client.scroll(
|
|
118
|
-
collection_name=test_collection,
|
|
119
|
-
order_by=OrderBy(key="timestamp", direction="desc"),
|
|
120
|
-
limit=3,
|
|
121
|
-
with_payload=["timestamp", "text"]
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
print(f"✅ OrderBy works! Found {len(results)} recent conversations:")
|
|
125
|
-
for r in results:
|
|
126
|
-
ts = r.payload.get('timestamp', 'N/A')
|
|
127
|
-
text = r.payload.get('text', '')[:60] + '...'
|
|
128
|
-
print(f" - {ts}: {text}")
|
|
129
|
-
|
|
130
|
-
except Exception as e:
|
|
131
|
-
print(f"❌ OrderBy test failed: {e}")
|
|
132
|
-
|
|
133
|
-
if __name__ == "__main__":
|
|
134
|
-
asyncio.run(add_timestamp_indexes())
|