CoolFace
Apppublic

Aigenthix/Graph_RAG

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
document_service.cpython-314.pyc26 linesDownload Raw Back to __pycache__
1+
2R6j����Rt^RIt^RIHt^RIHtHtHtHt^RI	H	t	^RI3Ht^RIt]P!]4t!RR4tR#)z*Document processing and management serviceN)�Path)�Optional�List�Dict�Any)�datetime)�uuid4c�a�]tRt^
toRtV3RlRltRV3RlRlltV3RlRltV3R	lR4ltV3RlRlt	V3R
lRlt5RtVtR#)�DocumentServicezService for managing documentsc� <�V^8�dQhRS[/#)��6upload_dir)�str)�format�
__classdict__s"��a/Users/ssp/Downloads/SSP/Claude folder/KnowledgeHut/POC1/backend/app/services/document_service.py�__annotate__�DocumentService.__annotate__s���7�7�3�7�c�n�\V4VnVPPRRR7/VnR#)T)�parents�exist_okN)rr
�mkdir�	documents)�selfr
s&&r�__init__�DocumentService.__init__s,���z�*��������d�T��:�46��rNc�t<�V^8�dQhRS[RS[RS[RS[S[S[S[3,,RS[S[S[3,/#)r�file_content�filename�
document_type�metadata�return)�bytesrrrr)rrs"�rrrsR����������	�7�4��S��>�*��8�c�3�h��
rc��\"�\\44pVPVRV2,pVPV4RTRTRTR\P9!4R\
V4R\V4R^R	T;'g//pWpPV&\PR10VRVR24V#5i)
zSave uploaded document�_�id�namer �upload_date�	file_size�	file_path�chunks_countr!zDocument saved: z (�))11rrr
�write_bytesr�now�lenr�logger�info)rrrr r!�doc_idr*�doc_infos&&&&&   r�
save_document�DocumentService.save_documents�����U�W����O�O����(��&<�<�	�	���l�+�
�&��H��]��8�<�<�>���\�*���Y���A�����B�	12��"*���v�����&�v�h�b��13�!�<�=���s�B*B,c�L<�V^8�dQhRS[RS[S[S[S[3,,/#�rr2r")rrrr)rrs"�rrr3s(���*�*�3�*�8�D��c��N�+C�*rc�8�VPPV4#)zGet document info)r�get)rr2s&&r�get_document�DocumentService.get_document3s���~�~�!�!�&�)�)rc�F<�V^8�dQhRS[S[S[S[3,,/#)rr")rrrr)rrs"�rrr7s!���-�-��T�#�s�(�^� 4�-rc�H�\VPP44#)zList all documents)�listr�values)rs&r�list_documents�DocumentService.list_documents7s���D�N�N�)�)�+�,�,rc�&<�V^8�dQhRS[RS[/#r7)r�bool)rrs"�rrr;s���14�15�c�16�d�17rc�18�WP9dsVPV,p\VR,4pVP4'dVP4VPV\PRV24R#R#)zDelete documentr*zDocument deleted: TF)rr�exists�unlinkr0r1)rr2�docr*s&&  r�delete_document�DocumentService.delete_document;sj���^�^�#��.�.��(�C��S��-�.�I����!�!�� � �"����v�&��K�K�,�V�H�5�6��rc�*<�V^8�dQhRS[RS[RR/#)rr2�countr"N)r�int)rrs"�rrrGs"���;�;�#�;�c�;�d�;rc�T�WP9dW PV,R&R#R#)zUpdate chunk count for documentr+N)r)rr2rKs&&&r�update_chunks_count�#DocumentService.update_chunks_countGs"���^�^�#�5:�N�N�6�"�>�2�$r)rr
)N)
�__name__�19__module__�__qualname__�__firstlineno__�__doc__rr4r:r@rHrN�__static_attributes__�__classdictcell__)rs@rr20r21
sD����(�7�7�22��<*�*�-�-�23�24�;�;rr25)rT�os�pathlibr�typingrrrrr�uuidr�logging�	getLoggerrPr0r26�rr�<module>r^s7��0�	��,�,����	�	�	�8�	$��=;�=;r