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
|
# Standard field definitions für document metadata
|
||||||
if field_definitions is None:
|
if field_definitions is None:
|
||||||
field_definitions = [
|
field_definitions = [
|
||||||
{"key": "document_name", "inject_into_chunk": True},
|
{"key": "document_name", "inject_into_chunk": True},
|
||||||
{"key": "description", "inject_into_chunk": True},
|
{"key": "description", "inject_into_chunk": True},
|
||||||
{"key": "created_at", "inject_into_chunk": False},
|
{"key": "advoware_art", "inject_into_chunk": True},
|
||||||
{"key": "modified_at", "inject_into_chunk": False},
|
{"key": "advoware_bemerkung", "inject_into_chunk": True},
|
||||||
{"key": "espocrm_id", "inject_into_chunk": False}
|
{"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()
|
session = await self._get_session()
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ class XAIUploadUtils:
|
|||||||
metadata={
|
metadata={
|
||||||
'espocrm_entity_type': 'CAkten',
|
'espocrm_entity_type': 'CAkten',
|
||||||
'espocrm_entity_id': akte_id,
|
'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']
|
collection_id = col['id']
|
||||||
@@ -157,6 +158,19 @@ class XAIUploadUtils:
|
|||||||
await xai.add_to_collection(collection_id, new_xai_file_id)
|
await xai.add_to_collection(collection_id, new_xai_file_id)
|
||||||
self._log.info(f" ✅ Added to collection {collection_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
|
# Update CDokumente with sync result
|
||||||
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
await espocrm.update_entity('CDokumente', doc_id, {
|
await espocrm.update_entity('CDokumente', doc_id, {
|
||||||
|
|||||||
Reference in New Issue
Block a user