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

Function adapt_array

methods/letta/orm/sqlite_functions.py:12–27  ·  view source on GitHub ↗

Converts numpy array to binary for SQLite storage

(arr)

Source from the content-addressed store, hash-verified

10
11
12def adapt_array(arr):
13 """
14 Converts numpy array to binary for SQLite storage
15 """
16 if arr is None:
17 return None
18
19 if isinstance(arr, list):
20 arr = np.array(arr, dtype=np.float32)
21 elif not isinstance(arr, np.ndarray):
22 raise ValueError(f"Unsupported type: {type(arr)}")
23
24 # Convert to bytes and then base64 encode
25 bytes_data = arr.tobytes()
26 base64_data = base64.b64encode(bytes_data)
27 return sqlite3.Binary(base64_data)
28
29
30def convert_array(text):

Callers 2

_build_passage_queryMethod · 0.90
listMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected