#!/usr/bin/env python3
"""Debug exactly what checkpoint is being loaded"""
import sys
sys.path.insert(0, 'c:/MONIKA')

from salience_os_seed.conversation.session import ConversationSession, ConversationConfig
from pathlib import Path
import torch

print("Creating ConversationSession...")
config = ConversationConfig()
print(f"Config checkpoint_path: {config.lm.checkpoint_path}")

# Check what's in the checkpoint file
ckpt_path = Path(config.lm.checkpoint_path)
if ckpt_path.exists():
    print(f"\nCheckpoint file exists: {ckpt_path}")
    ckpt = torch.load(ckpt_path, map_location='cpu')
    print(f"Checkpoint step: {ckpt.get('step', 'N/A')}")
    print(f"Checkpoint vocab size: {len(ckpt.get('vocab', {}).get('tokens', []))}")
else:
    print(f"\nCheckpoint file DOES NOT EXIST: {ckpt_path}")

# Now create session and see what it actually loads
session = ConversationSession(config)
print(f"\nAfter session creation:")
print(f"Session proto_lm step: {session.proto_lm.step}")
print(f"Session proto_lm vocab size: {session.proto_lm.vocab.size()}")
print(f"Session proto_lm has ' Hello': {' Hello' in session.proto_lm.vocab.token_to_id}")
