MCPcopy Create free account
hub / github.com/microsoft/SkillOpt / get_adapter

Function get_adapter

scripts/train.py:98–118  ·  view source on GitHub ↗

Instantiate the environment adapter specified in ``cfg["env"]``.

(cfg: dict)

Source from the content-addressed store, hash-verified

96
97
98def get_adapter(cfg: dict):
99 """Instantiate the environment adapter specified in ``cfg["env"]``."""
100 _register_builtins()
101 env_name = cfg.get("env", "alfworld")
102 if env_name not in _ENV_REGISTRY:
103 raise ValueError(
104 f"Unknown environment '{env_name}'. "
105 f"Available: {list(_ENV_REGISTRY.keys())}"
106 )
107 adapter_cls = _ENV_REGISTRY[env_name]
108
109 # Inspect adapter __init__ signature and only pass accepted kwargs
110 import inspect
111 sig = inspect.signature(adapter_cls.__init__)
112 accepted = set(sig.parameters.keys()) - {"self"}
113 adapter_kwargs: dict = {}
114 for key in accepted:
115 if key in cfg:
116 adapter_kwargs[key] = cfg[key]
117
118 return adapter_cls(**adapter_kwargs)
119
120
121# ── CLI ──────────────────────────────────────────────────────────────────────

Callers 1

mainFunction · 0.70

Calls 2

getMethod · 0.80
_register_builtinsFunction · 0.70

Tested by

no test coverage detected