File size: 2,076 Bytes
399b80c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from importlib import import_module as _imp
from typing import Dict as _Dict, Any as _Any, TYPE_CHECKING as _TYPE_CHECKING

if _TYPE_CHECKING:
    from openspace.tool_layer import OpenSpace as OpenSpace, OpenSpaceConfig as OpenSpaceConfig
    from openspace.agents import GroundingAgent as GroundingAgent
    from openspace.llm import LLMClient as LLMClient
    from openspace.recording import RecordingManager as RecordingManager

__version__ = "0.1.0"

__all__ = [
    # Version
    "__version__",
    
    # Main API
    "OpenSpace",
    "OpenSpaceConfig",

    # Core Components
    "GroundingAgent",
    "GroundingClient",
    "LLMClient",
    "BaseTool",
    "ToolResult",
    "BackendType",

    # Recording System
    "RecordingManager",
    "RecordingViewer",
]

# Map attribute → sub-module that provides it
_attr_to_module: _Dict[str, str] = {
    # Main API
    "OpenSpace": "openspace.tool_layer",
    "OpenSpaceConfig": "openspace.tool_layer",

    # Core Components
    "GroundingAgent": "openspace.agents",
    "GroundingClient": "openspace.grounding.core.grounding_client",
    "LLMClient": "openspace.llm",
    "BaseTool": "openspace.grounding.core.tool.base",
    "ToolResult": "openspace.grounding.core.types",
    "BackendType": "openspace.grounding.core.types",

    # Recording System
    "RecordingManager": "openspace.recording",
    "RecordingViewer": "openspace.recording.viewer",
}


def __getattr__(name: str) -> _Any:
    """Dynamically import sub-modules on first attribute access.

    This keeps the *initial* package import lightweight and avoids raising
    `ModuleNotFoundError` for optional / heavy dependencies until the
    corresponding functionality is explicitly used.
    """
    if name not in _attr_to_module:
        raise AttributeError(f"module 'openspace' has no attribute '{name}'")

    module_name = _attr_to_module[name]
    module = _imp(module_name)
    value = getattr(module, name)
    globals()[name] = value 
    return value


def __dir__():
    return sorted(list(globals().keys()) + list(_attr_to_module.keys()))