Python: VolatileMemoryStore.get_nearest_match returns an un-awaited coroutine instead of a (MemoryRecord, score) tuple
メンテナーはふだん 6 日以内に返信
評価
調査の方向性
python/semantic_kernel/memory/volatile_memory_store.py の VolatileMemoryStore.get_nearest_match から始め、次に動作するリファレンスとして ChromaMemoryStore.get_nearest_match と比較します。再現した呼び出しを対象とするリグレッションテストを追加し、未 await の coroutine を残さず、単一の (MemoryRecord, score) タプルを返すことを確認します。
索引モデルが issue の本文から書いたものです。
説明
What happens
VolatileMemoryStore.get_nearest_match is declared async def, but it returns the result of calling self.get_nearest_matches(...) without awaiting it. get_nearest_matches is also async def, so await store.get_nearest_match(...) gives the caller a coroutine, not the tuple[MemoryRecord, float] the signature promises. The inner coroutine is never run and Python warns "coroutine ... was never awaited". Even if it were awaited, it would be a list of tuples, not a single tuple.
Where
python/semantic_kernel/memory/volatile_memory_store.py, get_nearest_match (current main):
) -> tuple[MemoryRecord, float]:
...
return self.get_nearest_matches(
collection_name=collection_name,
embedding=embedding,
limit=1,
min_relevance_score=min_relevance_score,
with_embeddings=with_embedding,
)
Reproduce
import asyncio, numpy as np
from semantic_kernel.memory.volatile_memory_store import VolatileMemoryStore
from semantic_kernel.memory.memory_record import MemoryRecord
async def main():
s = VolatileMemoryStore()
await s.create_collection("c")
await s.upsert("c", MemoryRecord.local_record("id1", "text", "desc", None, np.array([1.0, 0.0])))
m = await s.get_nearest_match("c", np.array([1.0, 0.0]))
print(type(m))
asyncio.run(main())
Output on semantic-kernel main (also 1.44.1): <class 'coroutine'>
Expected
await store.get_nearest_match(...) returns a (MemoryRecord, score) tuple, as MemoryStoreBase.get_nearest_match documents. ChromaMemoryStore.get_nearest_match already does this: results = await self.get_nearest_matches(...) followed by return results[0].
Notes
The class is deprecated, but it is still exported from semantic_kernel.memory. I can send a fix with a test.
- 主要言語
- C#
- スター
- 28.7k
- フォーク
- 4.8k
- 平均マージ
- 7日 5時間
- マージ済み PR(30日)
- 59
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/semantic-kernel のほかの issue
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23対応中かも @nightcityblade が 24 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
microsoft/semantic-kernel#14526 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)対応中かも @VANDRANKI が 26 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/semantic-kernel#14522 ·
メンテナーはふだん 6 日以内に返信
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URI対応中かも @Laurianti が 26 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/semantic-kernel#14518 ·
メンテナーはふだん 6 日以内に返信
-
Python: FunctionCallContent.combine_arguments drops a streamed "{}" chunk, producing invalid JSON arguments対応中かも @VANDRANKI が 27 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/semantic-kernel#14512 · コメント 2 件 ·
メンテナーはふだん 6 日以内に返信
-
Python: NAMED_ARG_REGEX character-class bug [${1}] lets non-$-prefixed values ({, 1, }) be silently parsed as variable references対応中かも @aniketkrs が 30 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
microsoft/semantic-kernel#14491 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
microsoft/semantic-kernel の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
Tyrrrz/YoutubeDownloader#912 ·
-
broken link websiteオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
README says main uses .NET 9 while the current branch targets .NET 10対応中かも @dajiaohuang が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
ardalis/CleanArchitecture#1098 ·
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
madeyoga/AuthEndpoints#365 ·
メンテナーはふだん 1 日以内に返信