import socket
import struct
import json
def query_memory(query_text, k=10):
host = 'localhost'
port = 6060
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((host, port))
query_bytes = query_text.encode('utf-8')
s.sendall(struct.pack('<I', len(query_bytes)))
s.sendall(query_bytes)
print(f"Query sent: {query_text}")
print("Note: The server must be running with 'microscope-mem spine'.")
except ConnectionRefusedError:
print("Error: Could not connect to Microscope Memory. Is 'microscope-mem spine' running?")
if __name__ == "__main__":
query_memory("What are the depth levels of the cognitive index?")