feat: improve metadata handling in connector service (#11421)

### What problem does this PR solve?

- Update sync data source to handle metadata properly

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
Levi
2025-11-26 12:55:48 +01:00
committed by GitHub
parent 376eb15c63
commit 12979a3f21
5 changed files with 22 additions and 4 deletions

View File

@ -75,8 +75,9 @@ class SyncBase:
min_update = min([doc.doc_updated_at for doc in document_batch])
max_update = max([doc.doc_updated_at for doc in document_batch])
next_update = max([next_update, max_update])
docs = [
{
docs = []
for doc in document_batch:
doc_dict = {
"id": doc.id,
"connector_id": task["connector_id"],
"source": self.SOURCE_NAME,
@ -86,8 +87,10 @@ class SyncBase:
"doc_updated_at": doc.doc_updated_at,
"blob": doc.blob,
}
for doc in document_batch
]
# Add metadata if present
if doc.metadata:
doc_dict["metadata"] = doc.metadata
docs.append(doc_dict)
try:
e, kb = KnowledgebaseService.get_by_id(task["kb_id"])