MCPcopy Create free account
hub / github.com/Forethought-Technologies/AutoChain / get_from_env

Function get_from_env

autochain/utils.py:27–38  ·  view source on GitHub ↗

Get a value from a dictionary or an environment variable.

(key: str, env_key: str, default: Optional[str] = None)

Source from the content-addressed store, hash-verified

25
26
27def get_from_env(key: str, env_key: str, default: Optional[str] = None) -> str:
28 """Get a value from a dictionary or an environment variable."""
29 if env_key in os.environ and os.environ[env_key]:
30 return os.environ[env_key]
31 elif default is not None:
32 return default
33 else:
34 raise ValueError(
35 f"Did not find {key}, please add an environment variable"
36 f" `{env_key}` which contains it, or pass"
37 f" `{key}` as a named parameter."
38 )
39
40
41def get_args():

Callers 1

get_from_dict_or_envFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected