openenv/echo_env
6
1# SPDX-License-Identifier: BSD-3-Clause2 3"""Core components for agentic environments."""4 5from __future__ import annotations6 7from importlib import import_module8from typing import TYPE_CHECKING9 10from . import env_server11from .env_server import * # noqa: F40312 13if TYPE_CHECKING:14 from .env_client import EnvClient15 from .generic_client import GenericAction, GenericEnvClient16 from .llm_client import (17 AnthropicClient,18 create_llm_client,19 LLMClient,20 LLMResponse,21 OpenAIClient,22 ToolCall,23 )24 from .mcp_client import MCPClientBase, MCPToolClient25 from .sync_client import SyncEnvClient26 27__all__ = [28 "EnvClient",29 "SyncEnvClient",30 "GenericEnvClient",31 "GenericAction",32 "MCPClientBase",33 "MCPToolClient",34 "AnthropicClient",35 "LLMClient",36 "LLMResponse",37 "OpenAIClient",38 "ToolCall",39 "create_llm_client",40] + env_server.__all__ # type: ignore41 42 43_LAZY_ATTRS = {44 "EnvClient": (".env_client", "EnvClient"),45 "SyncEnvClient": (".sync_client", "SyncEnvClient"),46 "GenericEnvClient": (".generic_client", "GenericEnvClient"),47 "GenericAction": (".generic_client", "GenericAction"),48 "MCPClientBase": (".mcp_client", "MCPClientBase"),49 "MCPToolClient": (".mcp_client", "MCPToolClient"),50 "AnthropicClient": (".llm_client", "AnthropicClient"),51 "LLMClient": (".llm_client", "LLMClient"),52 "LLMResponse": (".llm_client", "LLMResponse"),53 "OpenAIClient": (".llm_client", "OpenAIClient"),54 "ToolCall": (".llm_client", "ToolCall"),55 "create_llm_client": (".llm_client", "create_llm_client"),56}57 58 59def __getattr__(name: str):60 if name in _LAZY_ATTRS:61 module_path, attr_name = _LAZY_ATTRS[name]62 module = import_module(module_path, __name__)63 value = getattr(module, attr_name)64 globals()[name] = value65 return value66 67 try:68 value = getattr(env_server, name)69 except AttributeError as exc:70 raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from exc71 72 globals()[name] = value73 return value74 75 76def __dir__() -> list[str]:77 return sorted(set(globals().keys()) | set(__all__))78 