File size: 3,181 Bytes
90c099b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""
Shared utilities for the unified review system.
"""
# Core utilities (always available)
from .json_parser import (
    parse_review_markdown,
    parse_keywords_json,
    parse_summary_json,
    parse_json_response,
)

from .prompt_loader import get_prompt_loader

# API Key Pool and Endpoint Pool (always available)
try:
    from .asta_api_key_pool import AstaAPIKeyPool
    _all_pools = ['AstaAPIKeyPool']
except ImportError:
    AstaAPIKeyPool = None
    _all_pools = []

try:
    from .vllm_endpoint_pool import VLLMEndpointPool
    _all_pools.append('VLLMEndpointPool')
except ImportError:
    VLLMEndpointPool = None

if _all_pools:
    __all__ = _all_pools

# Lazy imports for heavy dependencies (LLM-related)
# These may fail if dependencies are not installed, but that's okay
def _lazy_import_llm_services():
    """Lazy import LLM services to avoid dependency issues"""
    try:
        from .llm_service import LLMService, ChatMessage
        from .llm_service_factory import (
            get_llm_service_factory,
            LLMServiceFactory,
            load_api_key_from_config,
        )
        return {
            'LLMService': LLMService,
            'ChatMessage': ChatMessage,
            'get_llm_service_factory': get_llm_service_factory,
            'LLMServiceFactory': LLMServiceFactory,
            'load_api_key_from_config': load_api_key_from_config,
        }
    except ImportError:
        return {}

def _lazy_import_llm_implementations():
    """Lazy import LLM service implementations"""
    result = {}
    try:
        from .vllm_service import VLLMService
        result['VLLMService'] = VLLMService
    except ImportError:
        pass
    
    try:
        from .gpt_service import GPTService
        result['GPTService'] = GPTService
    except ImportError:
        pass
    
    try:
        from .mock_llm_service import MockLLMService, extract_title_from_latex, extract_abstract_from_latex
        result['MockLLMService'] = MockLLMService
        result['extract_title_from_latex'] = extract_title_from_latex
        result['extract_abstract_from_latex'] = extract_abstract_from_latex
    except ImportError:
        pass
    
    return result

def _lazy_import_other():
    """Lazy import other utilities"""
    result = {}
    try:
        from .reranker import rerank_paragraphs_bge
        result['rerank_paragraphs_bge'] = rerank_paragraphs_bge
    except ImportError:
        pass
    
    try:
        from .review_logger import ReviewLogger
        result['ReviewLogger'] = ReviewLogger
    except ImportError:
        pass
    
    return result

# Populate __all__ dynamically
_llm_services = _lazy_import_llm_services()
_llm_impls = _lazy_import_llm_implementations()
_other = _lazy_import_other()

# Make all lazy imports available at module level
globals().update(_llm_services)
globals().update(_llm_impls)
globals().update(_other)

__all__ = [
    'parse_review_markdown',
    'parse_keywords_json',
    'parse_summary_json',
    'parse_json_response',
    'get_prompt_loader',
] + list(_llm_services.keys()) + list(_llm_impls.keys()) + list(_other.keys())

if AstaAPIKeyPool:
    __all__.append('AstaAPIKeyPool')