MCPcopy Create free account
hub / github.com/modelscope/ms-agent / process_dict

Function process_dict

ms_agent/tools/search_engine.py:77–98  ·  view source on GitHub ↗

Recursively process dictionary to replace environment variables. Args: config (Dict[str, Any]): The configuration dictionary to process. Returns: Dict[str, Any]: The processed configuration dictionary with environment variables replaced.

(config: Dict[str, Any])

Source from the content-addressed store, hash-verified

75
76
77def process_dict(config: Dict[str, Any]) -> Dict[str, Any]:
78 """
79 Recursively process dictionary to replace environment variables.
80
81 Args:
82 config (Dict[str, Any]): The configuration dictionary to process.
83
84 Returns:
85 Dict[str, Any]: The processed configuration dictionary with environment variables replaced.
86 """
87 if not config:
88 return {}
89
90 result = {}
91 for key, value in config.items():
92 if isinstance(value, dict):
93 result[key] = process_dict(value)
94 elif isinstance(value, str):
95 result[key] = replace_env_vars(value)
96 else:
97 result[key] = value
98 return result
99
100
101def replace_env_vars(value: str) -> str:

Callers 1

load_base_configFunction · 0.85

Calls 1

replace_env_varsFunction · 0.85

Tested by

no test coverage detected