You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded) #14522
VolatileMemoryStore.get_batch and get_nearest_matches take a flag (with_embeddings) that is documented as "Whether to include the embeddings in the results". With the flag False (the default) the embeddings are still returned. The code makes a deepcopy and clears the embedding on the copy, but the loop variable is rebound and the copy is thrown away, so the original records are returned unchanged.
get (the single-record version) does this correctly, which shows the intended behavior.
Where
python/semantic_kernel/memory/volatile_memory_store.py on current main.
get_batch:
ifnotwith_embeddings:
# create copy of results without embeddingsforresultinresults:
result=deepcopy(result)
result._embedding=Nonereturnresults
get_nearest_matches:
ifnotwith_embeddings:
# create copy of results without embeddingsforresultintop_results:
result=deepcopy(result)
result[0]._embedding=Nonereturntop_results
In the second case deepcopy(result) copies the (record, score) tuple, and the copy is dropped. Note that a naive fix of removing the deepcopy would clear the embedding on the stored record itself, so the fix has to return copies.
All three return None for the embedding when the embeddings flag is False, and the stored records keep their embeddings. I am happy to send a fix with tests.
Activity