fix: restore embedded wiki images and optimize vector sync
This commit is contained in:
1 parent
30943159bf
commit
0c5e2e8cb0
23 files changed
+609
-136
No files matched your search
@@ -40,20 +40,31 @@ async def test_sql_store_atomically_replaces_vectors_and_marks_missing_deleted(t
|
||||
)
|
||||
await session.commit()
|
||||
|
||||
store = SqlLlmWikiIndexStore(session_factory)
|
||||
store = SqlLlmWikiIndexStore(session_factory, write_batch_size=1)
|
||||
assert await store.try_acquire_sync_lease("mapping-1", owner="worker", sync_id="sync-1", lease_seconds=60, fingerprint="fp")
|
||||
assert not await store.try_acquire_sync_lease("mapping-1", owner="worker", sync_id="sync-2", lease_seconds=60, fingerprint="fp")
|
||||
page = normalize_wiki_page("mapping-1", {"id": "p1", "slug": "people/alice", "title": "Alice", "content": "Alice founded Acme.", "status": "published"})
|
||||
blob, dimensions = encode_vector([3.0, 4.0], dimensions=2)
|
||||
saved = await store.replace_page_vectors(
|
||||
page=page,
|
||||
vectors=[{"section_index": 0, "heading": "History", "section_content": "Alice founded Acme.", "content_hash": "section", "embedding_dimensions": dimensions, "vector_blob": blob}],
|
||||
vectors=[
|
||||
{
|
||||
"section_index": index,
|
||||
"heading": "History",
|
||||
"section_content": f"Alice founded Acme. Part {index}",
|
||||
"content_hash": f"section-{index}",
|
||||
"embedding_dimensions": dimensions,
|
||||
"vector_blob": blob,
|
||||
}
|
||||
for index in range(3)
|
||||
],
|
||||
fingerprint="fp",
|
||||
sync_id="sync-1",
|
||||
)
|
||||
snapshot = await store.load_vector_snapshot("mapping-1", "fp")
|
||||
assert saved["slug"] == "people/alice"
|
||||
assert len(snapshot["rows"]) == 1
|
||||
assert store.write_batch_size == 1
|
||||
assert len(snapshot["rows"]) == 3
|
||||
assert decode_vector(snapshot["rows"][0]["vector_blob"], 2).tolist() == pytest.approx([0.6, 0.8])
|
||||
|
||||
assert await store.mark_missing_pages_deleted("mapping-1", "sync-2") == 1
|
||||
|
||||
Reference in new issue
Block a user