31 lines
1,007 B
Python
31 lines
1,007 B
Python
"""
|
|
Document Manager Module for handling document operations and content extraction.
|
|
"""
|
|
|
|
import base64
|
|
import logging
|
|
import uuid
|
|
|
|
from modules.interfaces.serviceChatModel import (
|
|
ChatDocument,
|
|
ExtractedContent
|
|
)
|
|
from modules.workflow.serviceContainer import ServiceContainer
|
|
from modules.workflow.processorDocument import DocumentProcessor
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class DocumentManager:
|
|
"""Manager for document operations and content extraction"""
|
|
|
|
def __init__(self, serviceContainer: ServiceContainer):
|
|
self.service = serviceContainer
|
|
self._processor = DocumentProcessor(serviceContainer)
|
|
|
|
async def extractContent(self, prompt: str, document: ChatDocument) -> ExtractedContent:
|
|
"""Extract content from document using prompt"""
|
|
try:
|
|
return await self._processor.processDocument(document, prompt)
|
|
except Exception as e:
|
|
logger.error(f"Error extracting from document: {str(e)}")
|
|
raise
|