MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / convert_array

Function convert_array

methods/letta/orm/sqlite_functions.py:30–50  ·  view source on GitHub ↗

Converts binary back to numpy array

(text)

Source from the content-addressed store, hash-verified

28
29
30def convert_array(text):
31 """
32 Converts binary back to numpy array
33 """
34 if text is None:
35 return None
36 if isinstance(text, list):
37 return np.array(text, dtype=np.float32)
38 if isinstance(text, np.ndarray):
39 return text
40
41 # Handle both bytes and sqlite3.Binary
42 binary_data = bytes(text) if isinstance(text, sqlite3.Binary) else text
43
44 try:
45 # First decode base64
46 decoded_data = base64.b64decode(binary_data)
47 # Then convert to numpy array
48 return np.frombuffer(decoded_data, dtype=np.float32)
49 except Exception:
50 return None
51
52
53def verify_embedding_dimension(embedding: np.ndarray, expected_dim: int = MAX_EMBEDDING_DIM) -> bool:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected