-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_converter.py
More file actions
78 lines (64 loc) · 2.35 KB
/
debug_converter.py
File metadata and controls
78 lines (64 loc) · 2.35 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
#!/usr/bin/env python
"""
Script to run the AgentFarm to Memory System converter.
"""
import logging
import sys
from pathlib import Path
from converter.config import DEFAULT_CONFIG
from converter.converter import from_agent_farm
def main():
db_path = "data/simulation.db"
output = "validation/memory_samples/agent_farm_memories.json"
validate = False
error_handling = "skip"
use_mock_redis = True
batch_size = 100
tiering_strategy = "simple"
log_file = "logs/converter.log"
# Create logs directory if it doesn't exist
log_dir = Path("logs")
log_dir.mkdir(exist_ok=True)
# Configure logging
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[
logging.FileHandler(log_file, mode="w"), # 'w' mode overwrites the file
logging.StreamHandler(sys.stdout),
],
force=True,
)
logger = logging.getLogger(__name__)
# Set all SQLAlchemy loggers to WARNING level to suppress most logs
logging.getLogger("sqlalchemy").setLevel(logging.WARNING)
logging.getLogger("sqlalchemy.engine").setLevel(logging.WARNING)
logging.getLogger("sqlalchemy.orm").setLevel(logging.WARNING)
logging.getLogger("sqlalchemy.pool").setLevel(logging.WARNING)
# Set all other loggers to DEBUG level
for name in logging.root.manager.loggerDict:
if not name.startswith("sqlalchemy"):
logging.getLogger(name).setLevel(logging.DEBUG)
logger.info(f"Logging to file: {log_file}")
# Prepare configuration
config = DEFAULT_CONFIG.copy()
config.update(
{
"validate": validate,
"error_handling": error_handling,
"use_mock_redis": True,
"batch_size": batch_size,
"tiering_strategy_type": tiering_strategy,
}
)
# Run converter
logger.info(f"Converting database: {db_path}")
memory_system = from_agent_farm(db_path, config)
return memory_system
if __name__ == "__main__":
memory_system = main()
agent = memory_system.agents["nWpvyFJReoFD5Fnq7AEggt"]
stats = agent.get_memory_statistics("nWpvyFJReoFD5Fnq7AEggt")
print(f"STM count: {stats['tiers']['stm']['count']}")
print(f"IM count: {stats['tiers']['im']['count']}")
print(f"LTM count: {stats['tiers']['ltm']['count']}")