MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / cosine_similarity

Function cosine_similarity

examples/mcpserver/memory.py:47–50  ·  view source on GitHub ↗
(a: list[float], b: list[float])

Source from the content-addressed store, hash-verified

45
46
47def cosine_similarity(a: list[float], b: list[float]) -> float:
48 a_array = np.array(a, dtype=np.float64)
49 b_array = np.array(b, dtype=np.float64)
50 return np.dot(a_array, b_array) / (np.linalg.norm(a_array) * np.linalg.norm(b_array))
51
52
53async def do_ai(

Callers 1

update_importanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected