improved dict score update

This commit is contained in:
joachim-danswer 2025-03-11 09:19:01 -07:00
parent 6b84332f1b
commit 838160e660

View File

@ -38,12 +38,11 @@ def update_chunk_boost_components__no_commit(
continue
score = data["boost_score"]
# this will be the only boost component for now
boost_components = {"information_content_boost": score}
if chunk_stats:
# Update existing record
chunk_stats.chunk_boost_components = boost_components
chunk_boost_components = dict(chunk_stats.chunk_boost_components)
chunk_boost_components["information_content_boost"] = score
chunk_stats.chunk_boost_components = chunk_boost_components
chunk_stats.last_modified = datetime.now(timezone.utc)
db_session.add(chunk_stats)
else:
@ -51,10 +50,13 @@ def update_chunk_boost_components__no_commit(
if score == 1.0:
continue
# Create new record
# this will be the only boost component for now
chunk_boost_components = {"information_content_boost": score}
chunk_stats = ChunkStats(
document_id=data["document_id"],
chunk_in_doc_id=chunk_in_doc_id,
chunk_boost_components=boost_components,
chunk_boost_components=chunk_boost_components,
)
db_session.add(chunk_stats)