import logging from typing import Dict, Any, List, Union from modules.aicore.aicoreBase import BaseConnectorAi from modules.datamodels.datamodelAi import AiModel, ModelCapabilitiesEnum, PriorityEnum, ProcessingModeEnum, OperationTypeEnum, AiModelCall, AiModelResponse # Configure logger logger = logging.getLogger(__name__) class AiInternal(BaseConnectorAi): """Internal connector for document processing, generation, and rendering.""" def __init__(self): super().__init__() logger.info("Internal Connector initialized") def getConnectorType(self) -> str: """Get the connector type identifier.""" return "internal" def getModels(self) -> List[AiModel]: """Get all available internal models.""" return [ AiModel( name="internal_extraction", displayName="Internal Document Extractor", connectorType="internal", maxTokens=0, # Not token-based contextLength=0, costPer1kTokensInput=0.0, costPer1kTokensOutput=0.0, speedRating=8, qualityRating=8, capabilities=[ModelCapabilitiesEnum.CONTENT_EXTRACTION, ModelCapabilitiesEnum.TEXT_EXTRACTION], functionCall=self.extractDocument, priority=PriorityEnum.COST, processingMode=ProcessingModeEnum.BASIC, operationTypes=[OperationTypeEnum.EXTRACT], version="internal-extractor-v1", calculatePriceUsd=lambda processingTime, bytesSent, bytesReceived: 0.001 + (bytesSent + bytesReceived) / (1024 * 1024) * 0.01 ), AiModel( name="internal_generation", displayName="Internal Document Generator", connectorType="internal", maxTokens=0, # Not token-based contextLength=0, costPer1kTokensInput=0.0, costPer1kTokensOutput=0.0, speedRating=7, qualityRating=8, capabilities=[ModelCapabilitiesEnum.TEXT_GENERATION, ModelCapabilitiesEnum.ANALYSIS], functionCall=self.generateDocument, priority=PriorityEnum.COST, processingMode=ProcessingModeEnum.BASIC, operationTypes=[OperationTypeEnum.GENERATE], version="internal-generator-v1", calculatePriceUsd=lambda processingTime, bytesSent, bytesReceived: 0.002 + (bytesReceived / (1024 * 1024)) * 0.005 ), AiModel( name="internal_rendering", displayName="Internal Document Renderer", connectorType="internal", maxTokens=0, # Not token-based contextLength=0, costPer1kTokensInput=0.0, costPer1kTokensOutput=0.0, speedRating=6, qualityRating=9, capabilities=[ModelCapabilitiesEnum.TEXT_GENERATION, ModelCapabilitiesEnum.ANALYSIS], functionCall=self.renderDocument, priority=PriorityEnum.QUALITY, processingMode=ProcessingModeEnum.DETAILED, operationTypes=[OperationTypeEnum.GENERATE], version="internal-renderer-v1", calculatePriceUsd=lambda processingTime, bytesSent, bytesReceived: 0.003 + (bytesReceived / (1024 * 1024)) * 0.008 ) ] async def extractDocument(self, modelCall: AiModelCall) -> AiModelResponse: """ NOP - we only need the model for price calculations """ logger.error(f"Document extraction not to call here") return AiModelResponse( content="", success=False, error="Internal connector should not be called directly" ) async def generateDocument(self, modelCall: AiModelCall) -> AiModelResponse: """ NOP - we only need the model for price calculations """ logger.error(f"Document generation not to call here") return AiModelResponse( content="", success=False, error="Internal connector should not be called directly" ) async def renderDocument(self, modelCall: AiModelCall) -> AiModelResponse: """ NOP - we only need the model for price calculations """ logger.error(f"Document rendering not to call here") return AiModelResponse( content="", success=False, error="Internal connector should not be called directly" )