Skip to content

Commit 87c9901

Browse files
authored
Merge pull request #105 from kazmer97/fix/idp-config-read-fixes
Config read bug fix
2 parents 45ad9b2 + fa2e381 commit 87c9901

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/idp_common_pkg/idp_common/utils/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import logging
77
from typing import Tuple, Dict, Any, Optional
88

9+
from idp_common.config.models import IDPConfig
10+
911
# Import yaml with fallback for systems that don't have it installed
1012
try:
1113
import yaml
@@ -620,7 +622,7 @@ def extract_structured_data_from_text(text: str, preferred_format: str = 'auto')
620622
logger.warning("Could not parse as either JSON or YAML, returning original text")
621623
return text, 'unknown'
622624

623-
def check_token_limit(document_text: str, extraction_results: Dict[str, Any], config: Dict[str, Any]) -> \
625+
def check_token_limit(document_text: str, extraction_results: Dict[str, Any], config: IDPConfig) -> \
624626
Optional[str]:
625627
"""
626628
Create token limit warning message based on the configured value of max_tokens
@@ -634,11 +636,11 @@ def check_token_limit(document_text: str, extraction_results: Dict[str, Any], co
634636
Error message based on the configured_max_tokens, None otherwise
635637
"""
636638
# Information for logging and troubleshooting
637-
assessment_config = config.get("assessment", {})
639+
assessment_config = config.assessment
638640
logger.info(f"assessment_config: {assessment_config}")
639-
model_id = config.get("model_id") or assessment_config.get("model", "unknown")
641+
model_id = assessment_config.model or "unknown"
640642
logger.info(f"model_id: {model_id}")
641-
configured_max_tokens = assessment_config.get("max_tokens")
643+
configured_max_tokens = assessment_config.max_tokens
642644
logger.info(f"configured_max_tokens: {configured_max_tokens}")
643645
estimated_tokens = (len(document_text) + len(str(extraction_results))) / 4
644646
logger.info(f"Estimated tokens: {estimated_tokens}")

0 commit comments

Comments
 (0)