fix(chunks): set position on remaining chunk insert paths

document_converters, the github size-fallback chunker, revert_service
restores, and the kb-persistence middleware now write explicit positions
(the middleware read path also orders by position).
This commit is contained in:
CREDO23 2026-06-12 18:53:08 +02:00
parent 7d55aaf2c1
commit 5a71769dba
4 changed files with 43 additions and 12 deletions

View file

@ -188,8 +188,10 @@ async def create_document_chunks(content: str) -> list[Chunk]:
chunk_texts = [c.text for c in config.chunker_instance.chunk(content)]
chunk_embeddings = await asyncio.to_thread(embed_texts, chunk_texts)
return [
Chunk(content=text, embedding=emb)
for text, emb in zip(chunk_texts, chunk_embeddings, strict=False)
Chunk(content=text, embedding=emb, position=i)
for i, (text, emb) in enumerate(
zip(chunk_texts, chunk_embeddings, strict=False)
)
]