feat(upload): Enhance document metadata handling with additional fields for better context
This commit is contained in:
@@ -227,11 +227,13 @@ class XAIService:
|
||||
# Standard field definitions für document metadata
|
||||
if field_definitions is None:
|
||||
field_definitions = [
|
||||
{"key": "document_name", "inject_into_chunk": True},
|
||||
{"key": "description", "inject_into_chunk": True},
|
||||
{"key": "created_at", "inject_into_chunk": False},
|
||||
{"key": "modified_at", "inject_into_chunk": False},
|
||||
{"key": "espocrm_id", "inject_into_chunk": False}
|
||||
{"key": "document_name", "inject_into_chunk": True},
|
||||
{"key": "description", "inject_into_chunk": True},
|
||||
{"key": "advoware_art", "inject_into_chunk": True},
|
||||
{"key": "advoware_bemerkung", "inject_into_chunk": True},
|
||||
{"key": "created_at", "inject_into_chunk": False},
|
||||
{"key": "modified_at", "inject_into_chunk": False},
|
||||
{"key": "espocrm_id", "inject_into_chunk": False},
|
||||
]
|
||||
|
||||
session = await self._get_session()
|
||||
|
||||
@@ -63,7 +63,8 @@ class XAIUploadUtils:
|
||||
metadata={
|
||||
'espocrm_entity_type': 'CAkten',
|
||||
'espocrm_entity_id': akte_id,
|
||||
'aktennummer': str(akte.get('aktennummer', '')),
|
||||
'aktenzeichen': str(akte.get('aktennummer', '')),
|
||||
'rubrum': str(akte.get('rubrum', '') or ''),
|
||||
}
|
||||
)
|
||||
collection_id = col['id']
|
||||
@@ -157,6 +158,19 @@ class XAIUploadUtils:
|
||||
await xai.add_to_collection(collection_id, new_xai_file_id)
|
||||
self._log.info(f" ✅ Added to collection {collection_id}")
|
||||
|
||||
# Set document metadata (injected into chunks for better AI context)
|
||||
try:
|
||||
await xai.update_document_metadata(collection_id, new_xai_file_id, {
|
||||
'document_name': doc.get('name', filename),
|
||||
'description': str(doc.get('beschreibung', '') or ''),
|
||||
'advoware_art': str(doc.get('advowareArt', '') or ''),
|
||||
'advoware_bemerkung': str(doc.get('advowareBemerkung', '') or ''),
|
||||
'espocrm_id': doc['id'],
|
||||
})
|
||||
self._log.info(f" ✅ Dokument-Metadaten gesetzt")
|
||||
except Exception as meta_err:
|
||||
self._log.warn(f" ⚠️ Metadaten-Update fehlgeschlagen (non-fatal): {meta_err}")
|
||||
|
||||
# Update CDokumente with sync result
|
||||
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
await espocrm.update_entity('CDokumente', doc_id, {
|
||||
|
||||
Reference in New Issue
Block a user